tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

console-namespace-object-class-string.any.js (1852B)


      1 // META: global=window,dedicatedworker,shadowrealm
      2 
      3 "use strict";
      4 // https://webidl.spec.whatwg.org/#es-namespaces
      5 // https://console.spec.whatwg.org/#console-namespace
      6 
      7 test(() => {
      8  assert_own_property(console, Symbol.toStringTag);
      9 
     10  const propDesc = Object.getOwnPropertyDescriptor(console, Symbol.toStringTag);
     11  assert_equals(propDesc.value, "console", "value");
     12  assert_equals(propDesc.writable, false, "writable");
     13  assert_equals(propDesc.enumerable, false, "enumerable");
     14  assert_equals(propDesc.configurable, true, "configurable");
     15 }, "@@toStringTag exists on the namespace object with the appropriate descriptor");
     16 
     17 test(() => {
     18  assert_equals(console.toString(), "[object console]");
     19  assert_equals(Object.prototype.toString.call(console), "[object console]");
     20 }, "Object.prototype.toString applied to the namespace object");
     21 
     22 test(t => {
     23  assert_own_property(console, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object");
     24  t.add_cleanup(() => {
     25    Object.defineProperty(console, Symbol.toStringTag, { value: "console" });
     26  });
     27 
     28  Object.defineProperty(console, Symbol.toStringTag, { value: "Test" });
     29  assert_equals(console.toString(), "[object Test]");
     30  assert_equals(Object.prototype.toString.call(console), "[object Test]");
     31 }, "Object.prototype.toString applied after modifying the namespace object's @@toStringTag");
     32 
     33 test(t => {
     34  assert_own_property(console, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object");
     35  t.add_cleanup(() => {
     36    Object.defineProperty(console, Symbol.toStringTag, { value: "console" });
     37  });
     38 
     39  assert_true(delete console[Symbol.toStringTag]);
     40  assert_equals(console.toString(), "[object Object]");
     41  assert_equals(Object.prototype.toString.call(console), "[object Object]");
     42 }, "Object.prototype.toString applied after deleting @@toStringTag");