|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +require('../common'); |
| 4 | + |
| 5 | +const assert = require('assert'); |
| 6 | +const { test, assert_equals, assert_true, assert_false } = |
| 7 | + require('../common/wpt'); |
| 8 | + |
| 9 | +assert.doesNotThrow(() => { |
| 10 | + global.console = global.console; |
| 11 | +}); |
| 12 | + |
| 13 | +const self = global; |
| 14 | + |
| 15 | +/* eslint-disable */ |
| 16 | +/* The following tests are copied from */ |
| 17 | +/* WPT Refs: |
| 18 | + https://github.com/w3c/web-platform-tests/blob/40e451c/console/console-is-a-namespace.any.js |
| 19 | + License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html |
| 20 | +*/ |
| 21 | + |
| 22 | +// https://heycam.github.io/webidl/#es-namespaces |
| 23 | +// https://console.spec.whatwg.org/#console-namespace |
| 24 | + |
| 25 | +test(() => { |
| 26 | + assert_true(self.hasOwnProperty("console")); |
| 27 | +}, "console exists on the global object"); |
| 28 | + |
| 29 | +test(() => { |
| 30 | + const propDesc = Object.getOwnPropertyDescriptor(self, "console"); |
| 31 | + assert_equals(propDesc.writable, true, "must be writable"); |
| 32 | + assert_equals(propDesc.enumerable, false, "must not be enumerable"); |
| 33 | + assert_equals(propDesc.configurable, true, "must be configurable"); |
| 34 | + assert_equals(propDesc.value, console, "must have the right value"); |
| 35 | +}, "console has the right property descriptors"); |
| 36 | + |
| 37 | +test(() => { |
| 38 | + assert_false("Console" in self); |
| 39 | +}, "Console (uppercase, as if it were an interface) must not exist"); |
| 40 | + |
| 41 | + |
| 42 | +// test(() => { |
| 43 | +// const prototype1 = Object.getPrototypeOf(console); |
| 44 | +// const prototype2 = Object.getPrototypeOf(prototype1); |
| 45 | + |
| 46 | +// assert_equals(Object.getOwnPropertyNames(prototype1).length, 0, "The [[Prototype]] must have no properties"); |
| 47 | +// assert_equals(prototype2, Object.prototype, "The [[Prototype]]'s [[Prototype]] must be %ObjectPrototype%"); |
| 48 | +// }, "The prototype chain must be correct"); |
| 49 | +/* eslint-enable */ |
0 commit comments