Skip to content

Commit

Permalink
squash: update test-console-is-a-namespace
Browse files Browse the repository at this point in the history
Update the test from the most recent WPT contents. Copyedit some
existing comments.
  • Loading branch information
Trott committed Aug 16, 2017
1 parent 8023728 commit 490374f
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions test/parallel/test-console-is-a-namespace.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,49 @@
'use strict';

// https://heycam.github.io/webidl/#es-namespaces
// https://console.spec.whatwg.org/#console-namespace
// https://github.com/w3c/web-platform-tests/blob/40e451c/console/console-is-a-namespace.any.js
require('../common');

const common = require('../common');
const assert = require('assert');
const { test, assert_equals, assert_true, assert_false } = common.WPT;
const { test, assert_equals, assert_true, assert_false } =
require('../common/wpt');

assert.doesNotThrow(() => {
global.console = global.console;
});

// Tests above are not from WPT.
// Tests below are from WPT.
const self = global;

/* eslint-disable */
/* The following tests are copied from */
/* WPT Refs:
https://github.com/w3c/web-platform-tests/blob/40e451c/console/console-is-a-namespace.any.js
License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
*/
/* Do not modify. */

test(() => {
assert_true(global.hasOwnProperty('console'));
}, 'console exists on the global object');
// https://heycam.github.io/webidl/#es-namespaces
// https://console.spec.whatwg.org/#console-namespace

test(() => {
assert_true(global.hasOwnProperty('console'));
}, 'console exists on the global object');
assert_true(self.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');
const propDesc = Object.getOwnPropertyDescriptor(self, "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');
assert_false("Console" in self);
}, "Console (uppercase, as if it were an interface) must not exist");

test(() => {
const prototype1 = Object.getPrototypeOf(console);
const prototype2 = Object.getPrototypeOf(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');
// test(() => {
// const prototype1 = Object.getPrototypeOf(console);
// const prototype2 = Object.getPrototypeOf(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 %ObjectPrototype%");
// }, "The prototype chain must be correct");
/* eslint-enable */

0 comments on commit 490374f

Please sign in to comment.