CSS-namespace-object-class-string.html (2002B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>CSSOM - Symbol.toStringTag value of CSS namespace object</title> 4 <link rel="help" href="https://webidl.spec.whatwg.org/#es-namespaces"> 5 <link rel="help" href="https://drafts.csswg.org/cssom/#namespacedef-css"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script> 9 "use strict"; 10 11 test(() => { 12 assert_own_property(CSS, Symbol.toStringTag); 13 14 const propDesc = Object.getOwnPropertyDescriptor(CSS, Symbol.toStringTag); 15 assert_equals(propDesc.value, "CSS", "value"); 16 assert_equals(propDesc.writable, false, "writable"); 17 assert_equals(propDesc.enumerable, false, "enumerable"); 18 assert_equals(propDesc.configurable, true, "configurable"); 19 }, "@@toStringTag exists on the namespace object with the appropriate descriptor"); 20 21 test(() => { 22 assert_equals(CSS.toString(), "[object CSS]"); 23 assert_equals(Object.prototype.toString.call(CSS), "[object CSS]"); 24 }, "Object.prototype.toString applied to the namespace object"); 25 26 test(t => { 27 assert_own_property(CSS, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); 28 t.add_cleanup(() => { 29 Object.defineProperty(CSS, Symbol.toStringTag, { value: "CSS" }); 30 }); 31 32 Object.defineProperty(CSS, Symbol.toStringTag, { value: "Test" }); 33 assert_equals(CSS.toString(), "[object Test]"); 34 assert_equals(Object.prototype.toString.call(CSS), "[object Test]"); 35 }, "Object.prototype.toString applied after modifying the namespace object's @@toStringTag"); 36 37 test(t => { 38 assert_own_property(CSS, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); 39 t.add_cleanup(() => { 40 Object.defineProperty(CSS, Symbol.toStringTag, { value: "CSS" }); 41 }); 42 43 assert_true(delete CSS[Symbol.toStringTag]); 44 assert_equals(CSS.toString(), "[object Object]"); 45 assert_equals(Object.prototype.toString.call(CSS), "[object Object]"); 46 }, "Object.prototype.toString applied after deleting @@toStringTag"); 47 </script>