dom/xbl/test/file_bug944407.xml

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 <?xml version="1.0"?>
     2 <bindings id="testBindings" xmlns="http://www.mozilla.org/xbl"
     3           xmlns:html="http://www.w3.org/1999/xhtml">
     4   <binding id="testAllowScript">
     5     <implementation>
     6        <property name="someProp" onget="return 2;" readonly="true"></property>
     7        <method name="someMethod"><body> return 3; </body></method>
     8        <method name="startTest">
     9          <body>
    10          <![CDATA[
    11            // Make sure we only get constructed when we're loaded from a domain
    12            // with script enabled.
    13            is(this.id, 'allow', "XBL should only be bound when the origin of the binding allows scripts");
    15            var t = this;
    16            doFinish = function() {
    17              // Take a moment to make sure that other constructors don't run when they shouldn't.
    18              if (t.id == 'allow')
    19                setTimeout(SpecialPowers.wrap(window.parent).finish, 100);
    20            }
    22            onTestEvent = function(target) {
    23              ok(true, 'called event handler');
    25              // Try calling event handlers on anonymous content.
    26              var e = new MouseEvent('click');
    27              document.getAnonymousNodes(target)[1].dispatchEvent(e);
    28              ok(window.calledEventHandlerOnAC, "Should invoke event handler on AC");
    30              // Now, dispatch a key event to test key handlers and move the test along.
    31              var k = document.createEvent('KeyboardEvent');
    32              k.initEvent('keyup', true, true);
    33              target.dispatchEvent(k);
    34            }
    36            // Check the implementation.
    37            is(this.someProp, 2, "Properties work");
    38            is(this.someMethod(), 3, "Methods work");
    40            // Kick over to the event handlers. This tests XBL event handlers,
    41            // XBL key handlers, and event handlers on anonymous content.
    42            this.dispatchEvent(new CustomEvent('testEvent'));
    43          ]]>
    44          </body>
    45        </method>
    47       <constructor>
    48       <![CDATA[
    49         win = XPCNativeWrapper.unwrap(window);
    50         SpecialPowers = win.SpecialPowers;
    51         ok = win.ok = SpecialPowers.wrap(window.parent).ok;
    52         is = win.is = SpecialPowers.wrap(window.parent).is;
    53         info = win.info = SpecialPowers.wrap(window.parent).info;
    55         info("Invoked constructor for " + this.id);
    57         var t = this;
    58         window.addEventListener('load', function loadListener() {
    59           window.removeEventListener('load', loadListener);
    60           // Wait two refresh-driver ticks to make sure that the constructor runs
    61           // for both |allow| and |deny| if it's ever going to.
    62           //
    63           // See bug 944407 comment 37.
    64           info("Invoked load listener for " + t.id);
    65           window.requestAnimationFrame(function() { window.requestAnimationFrame(t.startTest.bind(t)); });
    66         });
    67       ]]>
    68       </constructor>
    69     </implementation>
    70     <handlers>
    71       <handler event="testEvent" action="onTestEvent(this)" allowuntrusted="true"/>
    72       <handler event="keyup" action="ok(true, 'called key handler'); doFinish();" allowuntrusted="true"/>
    73     </handlers>
    74     <content>Anonymous Content<html:div onclick="window.calledEventHandlerOnAC = true;"></html:div><html:b style="display:none"><children/></html:b></content>
    75   </binding>
    76 </bindings>

mercurial