diff options
Diffstat (limited to 'testing/web-platform/tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/created-callback-element-prototype-test.html')
-rw-r--r-- | testing/web-platform/tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/created-callback-element-prototype-test.html | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/testing/web-platform/tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/created-callback-element-prototype-test.html b/testing/web-platform/tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/created-callback-element-prototype-test.html new file mode 100644 index 000000000..188957c1a --- /dev/null +++ b/testing/web-platform/tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/created-callback-element-prototype-test.html @@ -0,0 +1,87 @@ +<!DOCTYPE html> +<html> +<head> +<title>The custom element prototype must be set just prior to invoking created callback</title> +<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"> +<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> +<meta name="assert" content="The custom element prototype must be set just prior to invoking callback."> +<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> +</head> +<body> +<div id="log"></div> +<script> +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + + doc.body.innerHTML = '<x-a></x-a>'; + doc.registerElement('x-a', {prototype: proto}); + assert_equals(proto.createdCallbackThis.constructor.prototype, proto, + 'The custom element prototype is incorrect inside created callback'); +}, 'Test custom element prototype inside created callback when custom element is created ' + + 'in HTML before registration of a custom element'); + + +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + + doc.registerElement('x-b', {prototype: proto}); + doc.body.innerHTML = '<x-b></x-b>'; + assert_equals(proto.createdCallbackThis.constructor.prototype, proto, + 'The custom element prototype is incorrect inside created callback'); +}, 'Test custom element prototype inside created callback when custom element is created ' + + 'in HTML after registration of a custom element'); + + +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + var customElement = doc.createElement('x-c'); + + doc.body.appendChild(customElement); + doc.registerElement('x-c', {prototype: proto}); + assert_equals(proto.createdCallbackThis.constructor.prototype, proto, + 'The custom element prototype is incorrect inside created callback'); +}, 'Test custom element prototype inside created callback when custom element is created ' + + 'via document.createElement() before registration of a custom element'); + + +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + doc.registerElement('x-d', {prototype: proto}); + + var customElement = doc.createElement('x-d'); + doc.body.appendChild(customElement); + assert_equals(proto.createdCallbackThis.constructor.prototype, proto, + 'The custom element prototype is incorrect inside created callback'); +}, 'Test custom element prototype inside created callback when custom element is created ' + + 'via document.createElement() after registration of a custom element'); + + +test(function() { + var doc = newHTMLDocument(); + var proto = newHTMLElementPrototype(); + var GeneratedConstructor = doc.registerElement('x-e', {prototype: proto}); + var customElement = new GeneratedConstructor(); + + assert_equals(proto.createdCallbackThis.constructor.prototype, proto, + 'The custom element prototype is incorrect inside created callback'); +}, 'Test custom element prototype inside created callback when custom element is created ' + + 'via constructor returned by method registerElement'); + + +testInIFrame('../../resources/x-element.html', function(doc) { + var proto = newHTMLElementPrototype(); + doc.registerElement('x-element', {prototype: proto}); + assert_equals(proto.createdCallbackThis.constructor.prototype, proto, + 'The custom element prototype is incorrect inside created callback'); +}, 'Test custom element prototype inside created callback when custom element is created ' + + 'by UA parser before registration of a custom element'); +</script> +</body> +</html> |