dom/tests/mochitest/webcomponents/test_document_shared_registry.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=783129
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test shared registry for associated HTML documents.</title>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <div id="container"></div>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
michael@0 14 <script>
michael@0 15 var container = document.getElementById("container");
michael@0 16
michael@0 17 function createdCallbackFromMainDoc() {
michael@0 18 var createdCallbackCalled = false;
michael@0 19 var assocDoc = document.implementation.createHTMLDocument();
michael@0 20
michael@0 21 var proto = Object.create(HTMLElement.prototype);
michael@0 22 proto.createdCallback = function() {
michael@0 23 is(createdCallbackCalled, false, "created callback should only be called once in this tests.");
michael@0 24 createdCallbackCalled = true;
michael@0 25 runNextTest();
michael@0 26 };
michael@0 27
michael@0 28 assocDoc.registerElement("x-associated-doc-callback-elem", { prototype: proto });
michael@0 29 document.createElement("x-associated-doc-callback-elem");
michael@0 30 }
michael@0 31
michael@0 32 function createdCallbackFromAssociatedDoc() {
michael@0 33 var createdCallbackCalled = false;
michael@0 34 var assocDoc = document.implementation.createHTMLDocument();
michael@0 35
michael@0 36 var proto = Object.create(HTMLElement.prototype);
michael@0 37 proto.createdCallback = function() {
michael@0 38 is(createdCallbackCalled, false, "created callback should only be called once in this tests.");
michael@0 39 createdCallbackCalled = true;
michael@0 40 runNextTest();
michael@0 41 };
michael@0 42
michael@0 43 assocDoc.registerElement("x-main-doc-callback-elem", { prototype: proto });
michael@0 44 assocDoc.createElement("x-main-doc-callback-elem");
michael@0 45 }
michael@0 46
michael@0 47 function createdCallbackFromDocHTMLNamespace() {
michael@0 48 var createdCallbackCalled = false;
michael@0 49 var assocDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
michael@0 50 var somediv = assocDoc.createElement("div");
michael@0 51
michael@0 52 var proto = Object.create(HTMLElement.prototype);
michael@0 53 proto.createdCallback = function() {
michael@0 54 is(createdCallbackCalled, false, "created callback should only be called once in this tests.");
michael@0 55 createdCallbackCalled = true;
michael@0 56 runNextTest();
michael@0 57 };
michael@0 58
michael@0 59 assocDoc.registerElement("x-assoc-doc-with-ns-callback-elem", { prototype: proto });
michael@0 60 document.createElement("x-assoc-doc-with-ns-callback-elem");
michael@0 61 }
michael@0 62
michael@0 63 function registerNoRegistryDoc() {
michael@0 64 var assocDoc = document.implementation.createDocument(null, "html");
michael@0 65 try {
michael@0 66 assocDoc.registerElement("x-dummy", { prototype: Object.create(HTMLElement.prototype) });
michael@0 67 ok(false, "Registring element in document without registry should throw.");
michael@0 68 } catch (ex) {
michael@0 69 ok(true, "Registring element in document without registry should throw.");
michael@0 70 }
michael@0 71
michael@0 72 runNextTest();
michael@0 73 }
michael@0 74
michael@0 75 function runNextTest() {
michael@0 76 if (testFunctions.length > 0) {
michael@0 77 var nextTestFunction = testFunctions.shift();
michael@0 78 nextTestFunction();
michael@0 79 }
michael@0 80 }
michael@0 81
michael@0 82 var testFunctions = [
michael@0 83 createdCallbackFromAssociatedDoc,
michael@0 84 createdCallbackFromMainDoc,
michael@0 85 createdCallbackFromDocHTMLNamespace,
michael@0 86 registerNoRegistryDoc,
michael@0 87 SimpleTest.finish
michael@0 88 ];
michael@0 89
michael@0 90 SimpleTest.waitForExplicitFinish();
michael@0 91
michael@0 92 runNextTest();
michael@0 93 </script>
michael@0 94 </body>
michael@0 95 </html>

mercurial