OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> |
| 4 |
| 5 description("Verify 'class string' binding for WebIDL"); |
| 6 |
| 7 function verifyClassString(o, s) { |
| 8 // "Some objects described in this section are defined to have a class |
| 9 // string, which is the string to include in the string returned from |
| 10 // Object.prototype.toString. If an object has a class string, then the |
| 11 // object must, at the time it is created, have a property whose name is |
| 12 // the @@toStringTag symbol and whose value is the specified string." |
| 13 |
| 14 // TODO(jsbell): Willful violation. https://www.w3.org/Bugs/Public/show_bug
.cgi?id=28244 |
| 15 //shouldBeTrue("Object.prototype.hasOwnProperty.call(" + o + ", Symbol.toStr
ingTag)"); |
| 16 |
| 17 // TODO(jsbell): Verify writable/enumerable/configurable once WebIDL specs i
t. |
| 18 shouldBeEqualToString("Object.prototype.toString.call(" + o + ")", "[object
" + s + "]"); |
| 19 } |
| 20 |
| 21 // The class string of a platform object that implements one or more |
| 22 // interfaces must be the identifier of the primary interface of the |
| 23 // platform object. |
| 24 verifyClassString("window", "Window"); |
| 25 // 4.5.4: The class string of an interface prototype object is the |
| 26 // concatenation of the interface’s identifier and the string "Prototype". |
| 27 // TODO(jsbell): Willful violation. https://www.w3.org/Bugs/Public/show_bug.cgi
?id=28244 |
| 28 verifyClassString("window.__proto__", "Window"); |
| 29 verifyClassString("Window.prototype", "Window"); |
| 30 |
| 31 |
| 32 // TODO(jsbell): Verify class strings for platform array objects (4.2.26) |
| 33 // TODO(jsbell): Verify class strings for named properties objects (4.5.5) |
| 34 |
| 35 // The class string of a default iterator object for a given interface |
| 36 // is the result of concatenting the identifier of the interface and the |
| 37 // string " Iterator". |
| 38 verifyClassString("document.head.classList", "DOMTokenList"); |
| 39 verifyClassString("document.head.classList[Symbol.iterator]()", "DOMTokenList It
erator"); |
| 40 |
| 41 // The class string of an iterator prototype object for a given interface |
| 42 // is the result of concatenting the identifier of the interface and the |
| 43 // string "Iterator". |
| 44 verifyClassString("document.head.classList[Symbol.iterator]().__proto__", "DOMTo
kenListIterator"); |
| 45 |
| 46 // TODO(jsbell): DOMException |
| 47 // TODO(jsbell): DOMExceptionPrototype |
| 48 |
| 49 |
| 50 // And a few more interesting cases... |
| 51 verifyClassString("document", "HTMLDocument"); |
| 52 verifyClassString("document.__proto__", "HTMLDocument"); |
| 53 verifyClassString("HTMLDocument.prototype", "HTMLDocument"); |
| 54 |
| 55 // TODO(jsbell): Shadow roots |
| 56 |
| 57 // Constructor |
| 58 verifyClassString("new Blob", "Blob"); |
| 59 verifyClassString("(new Blob).__proto__", "Blob"); |
| 60 verifyClassString("Blob.prototype", "Blob"); |
| 61 |
| 62 // Factory |
| 63 verifyClassString("IDBKeyRange.only(0)", "IDBKeyRange"); |
| 64 verifyClassString("IDBKeyRange.only(0).__proto__", "IDBKeyRange"); |
| 65 verifyClassString("IDBKeyRange.prototype", "IDBKeyRange"); |
| 66 |
| 67 // Factory vs. Constructor |
| 68 verifyClassString("document.createElement('img')", "HTMLImageElement"); |
| 69 verifyClassString("document.createElement('img').__proto__", "HTMLImageElement")
; |
| 70 verifyClassString("new Image", "HTMLImageElement"); |
| 71 verifyClassString("(new Image).__proto__", "HTMLImageElement"); |
| 72 // Interesting: (new Image).__proto__ !== document.createElement('img').__proto_
_ |
| 73 verifyClassString("HTMLImageElement.prototype", "HTMLImageElement"); |
| 74 |
| 75 verifyClassString("new TransitionEvent('')", "TransitionEvent"); |
| 76 verifyClassString("new WebKitTransitionEvent('')", "TransitionEvent"); |
| 77 verifyClassString("TransitionEvent.prototype", "TransitionEvent"); |
| 78 verifyClassString("WebKitTransitionEvent.prototype", "TransitionEvent"); |
| 79 |
| 80 |
| 81 </script> |
OLD | NEW |