dom/tests/mochitest/webcomponents/test_document_register_parser.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.

     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 for elements created by the parser</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>
    12 var extendedButtonProto = Object.create(HTMLButtonElement.prototype);
    13 var buttonCallbackCalled = false;
    14 extendedButtonProto.createdCallback = function() {
    15   is(buttonCallbackCalled, false, "created callback for x-button should only be called once.");
    16   is(this.tagName, "BUTTON", "Only the <button> element should be upgraded.");
    17   buttonCallbackCalled = true;
    18 };
    20 document.registerElement("x-button", { prototype: extendedButtonProto, extends: "button" });
    22 var divProto = Object.create(HTMLDivElement.prototype);
    23 var divCallbackCalled = false;
    24 divProto.createdCallback = function() {
    25   is(divCallbackCalled, false, "created callback for x-div should only be called once.");
    26   is(buttonCallbackCalled, true, "crated callback should be called for x-button before x-div.");
    27   is(this.tagName, "X-DIV", "Only the <x-div> element should be upgraded.");
    28   divCallbackCalled = true;
    29   SimpleTest.finish();
    30 };
    32 document.registerElement("x-div", { prototype: divProto });
    34 SimpleTest.waitForExplicitFinish();
    35 </script>
    36 </head>
    37 <body>
    38 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
    39 <button is="x-button"></button><!-- should be upgraded -->
    40 <x-button></x-button><!-- should not be upgraded -->
    41 <span is="x-button"></span><!-- should not be upgraded -->
    42 <div is="x-div"></div><!-- should not be upgraded -->
    43 <x-div></x-div><!-- should be upgraded -->
    44 <script>
    45 </script>
    46 </body>
    47 </html>

mercurial