| Index: third_party/WebKit/LayoutTests/fast/js/webidl-class-strings.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/js/webidl-class-strings.html b/third_party/WebKit/LayoutTests/fast/js/webidl-class-strings.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3745501cacb23d4c00ec43cd741dab253cb835fa
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/fast/js/webidl-class-strings.html
|
| @@ -0,0 +1,81 @@
|
| +<!DOCTYPE html>
|
| +<script src="../../resources/js-test.js"></script>
|
| +<script>
|
| +
|
| +description("Verify 'class string' binding for WebIDL");
|
| +
|
| +function verifyClassString(o, s) {
|
| + // "Some objects described in this section are defined to have a class
|
| + // string, which is the string to include in the string returned from
|
| + // Object.prototype.toString. If an object has a class string, then the
|
| + // object must, at the time it is created, have a property whose name is
|
| + // the @@toStringTag symbol and whose value is the specified string."
|
| +
|
| + // TODO(jsbell): Willful violation. https://www.w3.org/Bugs/Public/show_bug.cgi?id=28244
|
| + //shouldBeTrue("Object.prototype.hasOwnProperty.call(" + o + ", Symbol.toStringTag)");
|
| +
|
| + // TODO(jsbell): Verify writable/enumerable/configurable once WebIDL specs it.
|
| + shouldBeEqualToString("Object.prototype.toString.call(" + o + ")", "[object " + s + "]");
|
| +}
|
| +
|
| +// The class string of a platform object that implements one or more
|
| +// interfaces must be the identifier of the primary interface of the
|
| +// platform object.
|
| +verifyClassString("window", "Window");
|
| +// 4.5.4: The class string of an interface prototype object is the
|
| +// concatenation of the interface’s identifier and the string "Prototype".
|
| +// TODO(jsbell): Willful violation. https://www.w3.org/Bugs/Public/show_bug.cgi?id=28244
|
| +verifyClassString("window.__proto__", "Window");
|
| +verifyClassString("Window.prototype", "Window");
|
| +
|
| +
|
| +// TODO(jsbell): Verify class strings for platform array objects (4.2.26)
|
| +// TODO(jsbell): Verify class strings for named properties objects (4.5.5)
|
| +
|
| +// The class string of a default iterator object for a given interface
|
| +// is the result of concatenting the identifier of the interface and the
|
| +// string " Iterator".
|
| +verifyClassString("document.head.classList", "DOMTokenList");
|
| +verifyClassString("document.head.classList[Symbol.iterator]()", "DOMTokenList Iterator");
|
| +
|
| +// The class string of an iterator prototype object for a given interface
|
| +// is the result of concatenting the identifier of the interface and the
|
| +// string "Iterator".
|
| +verifyClassString("document.head.classList[Symbol.iterator]().__proto__", "DOMTokenListIterator");
|
| +
|
| +// TODO(jsbell): DOMException
|
| +// TODO(jsbell): DOMExceptionPrototype
|
| +
|
| +
|
| +// And a few more interesting cases...
|
| +verifyClassString("document", "HTMLDocument");
|
| +verifyClassString("document.__proto__", "HTMLDocument");
|
| +verifyClassString("HTMLDocument.prototype", "HTMLDocument");
|
| +
|
| +// TODO(jsbell): Shadow roots
|
| +
|
| +// Constructor
|
| +verifyClassString("new Blob", "Blob");
|
| +verifyClassString("(new Blob).__proto__", "Blob");
|
| +verifyClassString("Blob.prototype", "Blob");
|
| +
|
| +// Factory
|
| +verifyClassString("IDBKeyRange.only(0)", "IDBKeyRange");
|
| +verifyClassString("IDBKeyRange.only(0).__proto__", "IDBKeyRange");
|
| +verifyClassString("IDBKeyRange.prototype", "IDBKeyRange");
|
| +
|
| +// Factory vs. Constructor
|
| +verifyClassString("document.createElement('img')", "HTMLImageElement");
|
| +verifyClassString("document.createElement('img').__proto__", "HTMLImageElement");
|
| +verifyClassString("new Image", "HTMLImageElement");
|
| +verifyClassString("(new Image).__proto__", "HTMLImageElement");
|
| +// Interesting: (new Image).__proto__ !== document.createElement('img').__proto__
|
| +verifyClassString("HTMLImageElement.prototype", "HTMLImageElement");
|
| +
|
| +verifyClassString("new TransitionEvent('')", "TransitionEvent");
|
| +verifyClassString("new WebKitTransitionEvent('')", "TransitionEvent");
|
| +verifyClassString("TransitionEvent.prototype", "TransitionEvent");
|
| +verifyClassString("WebKitTransitionEvent.prototype", "TransitionEvent");
|
| +
|
| +
|
| +</script>
|
|
|