dom/tests/mochitest/webcomponents/test_document_register_base_queue.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:b271b61ccf95
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=783129
5 -->
6 <head>
7 <title>Test for document.registerElement lifecycle callback</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 <script>
11 var p = Object.create(HTMLElement.prototype);
12
13 var createdCallbackCallCount = 0;
14
15 // By the time the base element queue is processed via the microtask,
16 // both x-hello elements should be in the document.
17 p.createdCallback = function() {
18 var one = document.getElementById("one");
19 var two = document.getElementById("two");
20 isnot(one, null, "First x-hello element should be in the tree.");
21 isnot(two, null, "Second x-hello element should be in the tree.");
22 createdCallbackCallCount++;
23 if (createdCallbackCallCount == 2) {
24 SimpleTest.finish();
25 }
26
27 if (createdCallbackCallCount > 2) {
28 ok(false, "Created callback called too much.");
29 }
30 };
31
32 p.attributeChangedCallback = function(name, oldValue, newValue) {
33 ok(false, "Attribute changed callback should not be called because callbacks should not be queued until created callback invoked.");
34 };
35
36 document.registerElement("x-hello", { prototype: p });
37
38 SimpleTest.waitForExplicitFinish();
39 </script>
40 </head>
41 <body>
42 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
43 <x-hello id="one"></x-hello>
44 <x-hello id="two"></x-hello>
45 <script>
46 </script>
47 </body>
48 </html>

mercurial