mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
Update web-platform-tests to revision 697b971060b2d475a73c1c3755232a4674d61cf5
This commit is contained in:
parent
f60598909a
commit
b97474fbba
236 changed files with 4817 additions and 893 deletions
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElement() and Document.createElementNS() create custom element of type, specified by localName argument</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="If an element definition with matching localName, namespace, and TYPE is not registered with token's document, set TYPE to localName">
|
||||
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
|
||||
<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 name1 = 'x-a';
|
||||
var name2 = 'x-b';
|
||||
var GeneratedConstructor = doc.registerElement(name1);
|
||||
var customElement = doc.createElement(name1, name2);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Custom element type should be the local name of the custom element');
|
||||
}, 'Test Document.createElement() creates custom element of type, ' +
|
||||
'specified by localName argument, if an element definition with matching localName, ' +
|
||||
'namespace, and type is not registered');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var name1 = 'x-c';
|
||||
var name2 = 'x-d';
|
||||
var GeneratedConstructor = doc.registerElement(name1);
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, name1, name2);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Custom element type should be the local name of the custom element');
|
||||
}, 'Test Document.createElementNS() creates custom element of type, ' +
|
||||
'specified by localName argument, if an element definition with matching ' +
|
||||
'localName, namespace, and type is not registered');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElement() and Document.createElementNS() create custom element of type, specified by typeExtension argument</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="If an element definition with matching localName, namespace, and TYPE is registered then typeExtension is a TYPE">
|
||||
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
|
||||
<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 name1 = 'x-a';
|
||||
var GeneratedConstructor1 = doc.registerElement(name1);
|
||||
var name2 = 'x-b';
|
||||
var GeneratedConstructor2 = doc.registerElement(name2);
|
||||
var customElement = doc.createElement(name1, name2);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
|
||||
'Custom element type should be the type extension of the custom element');
|
||||
}, 'Test Document.createElement() creates custom element of type, ' +
|
||||
'specified by typeExtension argument');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var name1 = 'x-c';
|
||||
var GeneratedConstructor1 = doc.registerElement(name1);
|
||||
var name2 = 'x-d';
|
||||
var GeneratedConstructor2 = doc.registerElement(name2);
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, name1, name2);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
|
||||
'Custom element type should be the type extension of the custom element');
|
||||
}, 'Test Document.createElementNS() creates custom element of type, ' +
|
||||
'specified by typeExtension argument');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var name1 = 'x-e';
|
||||
var name2 = 'x-f';
|
||||
var GeneratedConstructor2 = doc.registerElement(name2);
|
||||
var customElement = doc.createElement(name1, name2);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
|
||||
'Custom element type should be the type extension of the custom element');
|
||||
}, 'Test Document.createElement() creates custom element of type, ' +
|
||||
'specified by typeExtension argument. Definition for localName is absent');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var name1 = 'x-g';
|
||||
var name2 = 'x-h';
|
||||
var GeneratedConstructor2 = doc.registerElement(name2);
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, name1, name2);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
|
||||
'Custom element type should be the type extension of the custom element');
|
||||
}, 'Test Document.createElementNS() creates custom element of type, ' +
|
||||
'specified by typeExtension argument. Definition for localName is absent');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElement() and Document.createElementNS() set IS attribute to type</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="If TYPE is not the same as localName, set the value of ELEMENT's IS attribute to TYPE">
|
||||
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
|
||||
<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();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var obj = doc.createElement(tagName);
|
||||
var name = 'x-a-' + tagName;
|
||||
var proto = Object.create(obj.constructor.prototype);
|
||||
doc.registerElement(name, {prototype: proto, extends: tagName});
|
||||
var customElement = doc.createElement(tagName, name);
|
||||
assert_equals(customElement.getAttribute('is'), name,
|
||||
'Value of the IS attribute should be set to type by Document.createElement()');
|
||||
});
|
||||
}, 'Test Document.createElement() sets the element\'s IS attribute value to type, ' +
|
||||
'if type is not the same as localName');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var name = 'x-b-' + tagName;
|
||||
var customElement = doc.createElement(tagName, name);
|
||||
assert_equals(customElement.getAttribute('is'), name,
|
||||
'Value of the IS attribute should be set to type by Document.createElement()');
|
||||
});
|
||||
}, 'Test Document.createElement() sets the element\'s IS attribute value to type, ' +
|
||||
'if type is not the same as localName and an element definition with matching ' +
|
||||
'localName, namespace, and type is not registered');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var obj = doc.createElement(tagName);
|
||||
var name = 'x-c-' + tagName;
|
||||
var proto = Object.create(obj.constructor.prototype);
|
||||
doc.registerElement(name, {prototype: proto, extends: tagName});
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
|
||||
assert_equals(customElement.getAttribute('is'), name,
|
||||
'Value of the IS attribute should be set to type by Document.createElementNS()');
|
||||
});
|
||||
}, 'Test Document.createElementNS() sets the element\'s IS attribute value to type, ' +
|
||||
'if type is not the same as localName');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var name = 'x-d-' + tagName;
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
|
||||
assert_equals(customElement.getAttribute('is'), name,
|
||||
'Value of the IS attribute should be set to type by Document.createElementNS()');
|
||||
});
|
||||
}, 'Test Document.createElementNS() sets the element\'s IS attribute value to type, ' +
|
||||
'if type is not the same as localNameand and an element definition with matching ' +
|
||||
'localName, namespace, and type is not registered ');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElement() sets custom element namespace to HTML Namespace</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="Namespace for createElement is HTML Namespace">
|
||||
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
|
||||
<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 name = 'x-a';
|
||||
doc.registerElement(name);
|
||||
var customElement = doc.createElement(name);
|
||||
assert_equals(customElement.namespaceURI, HTML_NAMESPACE,
|
||||
'Custom element namespace should be HTML Namespace');
|
||||
}, 'Test Document.createElement() sets custom element namespace to HTML Namespace');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var name = 'x-b';
|
||||
var customElement = doc.createElement(name);
|
||||
assert_equals(customElement.namespaceURI, HTML_NAMESPACE,
|
||||
'Custom element namespace should be HTML Namespace');
|
||||
}, 'Test Document.createElement() sets custom element namespace to HTML Namespace ' +
|
||||
'and an element definition with matching localName, namespace, and type is not registered');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var obj = doc.createElement(tagName);
|
||||
var name = 'x-c-' + tagName;
|
||||
var proto = Object.create(obj.constructor.prototype);
|
||||
doc.registerElement(name, {
|
||||
prototype: Object.create(proto),
|
||||
extends: tagName
|
||||
});
|
||||
var customElement = doc.createElement(tagName, name);
|
||||
assert_equals(customElement.namespaceURI, HTML_NAMESPACE,
|
||||
'Custom element namespace for the element extending ' + tagName +
|
||||
' should be HTML Namespace');
|
||||
});
|
||||
}, 'Document.createElement() sets custom element namespace to HTML Namespace. ' +
|
||||
'Custom element is extending standard HTML tag');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var name = 'x-d-' + tagName;
|
||||
var customElement = doc.createElement(tagName, name);
|
||||
assert_equals(customElement.namespaceURI, HTML_NAMESPACE,
|
||||
'Custom element namespace for the element with tag name ' + tagName +
|
||||
' and type name ' + name + ' should be HTML Namespace');
|
||||
});
|
||||
}, 'Document.createElement() sets custom element namespace to HTML Namespace. ' +
|
||||
'Document.createElement() is called with standard HTML tag name and ' +
|
||||
'type without registered custom element of such type');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,47 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElement() and Document.createElementNS() create custom element of type, specified by typeExtension argument</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="Let TYPE be typeExtension, or localName if typeExtension is not present">
|
||||
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
|
||||
<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();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var obj = doc.createElement(tagName);
|
||||
var name = 'x-a-' + tagName;
|
||||
var proto = Object.create(obj.constructor.prototype);
|
||||
var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
|
||||
var customElement = doc.createElement(tagName, name);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Custom element type should be ' + name);
|
||||
});
|
||||
}, 'Test Document.createElement() creates custom element of type, ' +
|
||||
'specified by typeExtension argument');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var obj = doc.createElement(tagName);
|
||||
var name = 'x-b-' + tagName;
|
||||
var proto = Object.create(obj.constructor.prototype);
|
||||
var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Custom element type should be ' + name);
|
||||
});
|
||||
}, 'Test Document.createElementNS() creates custom element of type, ' +
|
||||
'specified by typeExtension argument');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElement() and Document.createElementNS() create custom element of type, specified by localName argument</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="If an element definition with matching localName, namespace, and TYPE is not registered with token's document, set TYPE to localName">
|
||||
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
|
||||
<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();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var obj = doc.createElement(tagName);
|
||||
var name = 'x-a-' + tagName;
|
||||
var proto = Object.create(obj.constructor.prototype);
|
||||
var customElement = doc.createElement(tagName, name);
|
||||
assert_equals(Object.getPrototypeOf(customElement), Object.getPrototypeOf(obj),
|
||||
'Unregistered custom element type should be a local name');
|
||||
|
||||
var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Registered custom element type should be the type extension');
|
||||
});
|
||||
}, 'If typeExtension is unresolved when createElement called then local name is a type');
|
||||
|
||||
|
||||
test (function() {
|
||||
var doc = newHTMLDocument();
|
||||
HTML5_ELEMENTS.forEach(function(tagName) {
|
||||
var obj = doc.createElement(tagName);
|
||||
var name = 'x-b-' + tagName;
|
||||
var proto = Object.create(obj.constructor.prototype);
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
|
||||
assert_equals(Object.getPrototypeOf(customElement), Object.getPrototypeOf(obj),
|
||||
'Custom element type should be a local name');
|
||||
|
||||
var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Custom element type should be the type extension');
|
||||
});
|
||||
}, 'If typeExtension is unresolved when createElementNS called then local name is a type');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElement() and Document.createElementNS() create custom element of type, specified by single localName argument</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="Let TYPE be typeExtension, or localName if typeExtension is not present">
|
||||
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
|
||||
<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 name = 'x-a';
|
||||
var GeneratedConstructor = doc.registerElement(name);
|
||||
var customElement = doc.createElement(name);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Custom element type should be the local name of the custom element');
|
||||
}, 'Test Document.createElement() creates custom element of type, ' +
|
||||
'specified by single localName argument');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var name = 'x-b';
|
||||
var GeneratedConstructor = doc.registerElement(name);
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, name);
|
||||
assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
|
||||
'Custom element type should be the local name of the custom element');
|
||||
}, 'Test Document.createElementNS() creates custom element of type, ' +
|
||||
'specified by localName argument. Argument typeExtension is not passed');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Document.createElementNS() 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.createElementNS() 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>
|
||||
</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.createElementNS(HTML_NAMESPACE, name);
|
||||
assert_equals(proto.createdCallbackCalledCounter, 1,
|
||||
'Callback created should be enqueued by Document.createElementNS()');
|
||||
}, 'Test Document.createElementNS() 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.createElementNS(HTML_NAMESPACE, name, name);
|
||||
assert_equals(proto.createdCallbackCalledCounter, 1,
|
||||
'Callback created should be enqueued by Document.createElementNS()');
|
||||
}, 'Test Document.createElementNS() with typeExtension argument enqueues created callback');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var proto = newHTMLElementPrototype();
|
||||
var name = 'x-c';
|
||||
var customElement = doc.createElementNS(HTML_NAMESPACE, name);
|
||||
assert_equals(proto.createdCallbackCalledCounter, 0,
|
||||
'Document.createElementNS() 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.createElementNS() 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.createElementNS(HTML_NAMESPACE, tagName, name);
|
||||
|
||||
assert_equals(proto.createdCallbackCalledCounter, 1,
|
||||
'Callback created should be enqueued by Document.createElementNS()');
|
||||
});
|
||||
}, 'Test Document.createElementNS() enqueues created callback for custom elements ' +
|
||||
'that are extensions of HTML5 elements');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,72 @@
|
|||
<!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>
|
||||
</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>
|
Loading…
Add table
Add a link
Reference in a new issue