dom/tests/mochitest/webcomponents/test_document_register_parser.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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