dom/tests/mochitest/webcomponents/test_document_register_base_queue.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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);
    13 var createdCallbackCallCount = 0;
    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   }
    27   if (createdCallbackCallCount > 2) {
    28     ok(false, "Created callback called too much.");
    29   }
    30 };
    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 };
    36 document.registerElement("x-hello", { prototype: p });
    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