diff options
Diffstat (limited to 'tests/wpt/web-platform-tests/custom-elements/instantiating-custom-elements/extensions-to-document-interface/created-callback-create-element.html')
m--------- | tests/wpt/web-platform-tests | 0 | ||||
-rw-r--r-- | tests/wpt/web-platform-tests/custom-elements/instantiating-custom-elements/extensions-to-document-interface/created-callback-create-element.html | 73 |
2 files changed, 73 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests b/tests/wpt/web-platform-tests deleted file mode 160000 -Subproject 29dfb8944e535d439ca94cf7d1b1d9138a8ad11 diff --git a/tests/wpt/web-platform-tests/custom-elements/instantiating-custom-elements/extensions-to-document-interface/created-callback-create-element.html b/tests/wpt/web-platform-tests/custom-elements/instantiating-custom-elements/extensions-to-document-interface/created-callback-create-element.html new file mode 100644 index 00000000000..0a557e5f85e --- /dev/null +++ b/tests/wpt/web-platform-tests/custom-elements/instantiating-custom-elements/extensions-to-document-interface/created-callback-create-element.html @@ -0,0 +1,73 @@ +<!DOCTYPE html> +<html> +<head> +<title>Document.createElement() must enqueue created callback for registered custom element type</title> +<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> +<meta name="assert" content="Document.createElement() must enqueue created callback for registered custom element type"> +<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate"> +<link rel="help" href="http://www.w3.org/TR/custom-elements/#types-of-callbacks"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../../testcommon.js"></script> +<link rel="stylesheet" href="/resources/testharness.css"> +</head> +<body> +<div id="log"></div> +<script> +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + var name = 'x-a'; + + doc.registerElement(name, {prototype: proto}); + var customElement = doc.createElement(name); + assert_equals(proto.createdCallbackCalledCounter, 1, + 'Callback created should be enqueued by Document.createElement()'); +}, 'Test Document.createElement() without typeExtension argument enqueues created callback'); + + +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + var name = 'x-b'; + + doc.registerElement(name, {prototype: proto}); + var customElement = doc.createElement(name, name); + assert_equals(proto.createdCallbackCalledCounter, 1, + 'Callback created should be enqueued by Document.createElement()'); +}, 'Test Document.createElement() with typeExtension argument enqueues created callback'); + + +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + var name = 'x-c'; + var customElement = doc.createElement(name); + assert_equals(proto.createdCallbackCalledCounter, 0, + 'Document.createElement() should not enqueue created callback ' + + 'for unresolved custom element'); + + doc.registerElement(name, {prototype: proto}); + assert_equals(proto.createdCallbackCalledCounter, 1, + 'Callback created should be called after custom element is registered'); +}, 'Document.createElement() should not enqueue created callback ' + + 'for unresolved custom element'); + + +test(function() { + var doc = newHTMLDocument(); + HTML5_ELEMENTS.forEach(function(tagName) { + var obj = doc.createElement(tagName); + var name = 'x-d-' + tagName; + var proto = newCustomElementPrototype(Object.create(obj.constructor.prototype)); + doc.registerElement(name, {prototype: proto, extends: tagName}); + var customElement = doc.createElement(tagName, name); + + assert_equals(proto.createdCallbackCalledCounter, 1, + 'Callback created should be enqueued by Document.createElement()'); + }); +}, 'Test Document.createElement() enqueues created callback for custom elements ' + + 'that are extensions of HTML5 elements'); +</script> +</body> +</html> |