forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
console: make console consistent with the standard - overridable
make console overridable by custom console( without delete ) add test suite from w3c/web-platform-tests( console-is-a-namespace ) few test cases commented out from the test suite to make nodejs console even more consistent further changes needed which will come in the next commit which could be more breaking than this one Fixes: nodejs#11805
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
// https://heycam.github.io/webidl/#es-namespaces | ||
// https://console.spec.whatwg.org/#console-namespace | ||
// https://github.com/w3c/web-platform-tests/blob/master/console/console-is-a-namespace.any.js | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { test, assert_equals, assert_true, assert_false } = common.WPT; | ||
|
||
assert.doesNotThrow(() => { | ||
global.console = global.console; | ||
}); | ||
|
||
test(() => { | ||
assert_true(global.hasOwnProperty('console')); | ||
}, 'console exists on the global object'); | ||
|
||
test(() => { | ||
assert_true(global.hasOwnProperty('console')); | ||
}, 'console exists on the global object'); | ||
|
||
test(() => { | ||
const propDesc = Object.getOwnPropertyDescriptor(global, 'console'); | ||
// assert_equals(propDesc.writable, true, 'must be writable'); | ||
// assert_equals(propDesc.enumerable, false, 'must not be enumerable'); | ||
assert_equals(propDesc.configurable, true, 'must be configurable'); | ||
// assert_equals(propDesc.value, console, 'must have the right value'); | ||
}, 'console has the right property descriptors'); | ||
|
||
test(() => { | ||
assert_false('Console' in global); | ||
}, 'Console (uppercase, as if it were an interface) must not exist'); | ||
|
||
test(() => { | ||
const prototype1 = Object.getPrototypeOf(console); | ||
const prototype2 = Object.getPrototypeOf(prototype1); | ||
// console.log('console',Object.getOwnPropertyNames(console)); | ||
// console.log('prototype1',Object.getOwnPropertyNames(prototype1)); | ||
// assert_equals(Object.getOwnPropertyNames(prototype1).length, 0, | ||
// 'The [[Prototype]] must have no properties'); | ||
assert_equals(prototype2, Object.prototype, | ||
'The [[Prototype]]\'s [[Prototype]] must be Object Prototype'); | ||
|
||
}, 'The prototype chain must be correct'); |