caps/tests/mochitest/test_app_principal_equality.html

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 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=777467
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test app principal's equality</title>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777467">Mozilla Bug 777467</a>
    14 <p id="display"></p>
    15 <script>
    16   // Initialization.
    17   SpecialPowers.addPermission("browser", true, document);
    18   SpecialPowers.addPermission("embed-apps", true, document);
    20   SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
    21   SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", false);
    22 </script>
    23 <div id="content" style="display: none;">
    24   <iframe src="error404"></iframe>
    25   <iframe mozbrowser src="error404"></iframe>
    26   <iframe mozapp="http://example.org/manifest.webapp" mozbrowser src="error404"></iframe>
    27 </div>
    28 <pre id="test">
    29 <script type="application/javascript">
    31 /** Test for app principal's equality **/
    33 SimpleTest.waitForExplicitFinish();
    35 function canAccessDocument(win) {
    36   var result = true;
    37   try {
    38     win.document;
    39   } catch(e) {
    40     result = false;
    41   }
    42   return result;
    43 }
    45 addLoadEvent(function() {
    46   // Test the witness frame (we can access same-origin frame).
    47   is(canAccessDocument(frames[0]), true,
    48      "should be able to access the first frame");
    50   // Test different app/browserElement frames.
    51   for (var i=1; i<frames.length; ++i) {
    52     is(canAccessDocument(frames[i]), false,
    53        "should not be able to access the other frames");
    54   }
    56   // Cleanup.
    57   SpecialPowers.clearUserPref('dom.mozBrowserFramesEnabled');
    58   SpecialPowers.clearUserPref('dom.ipc.browser_frames.oop_by_default');
    59   SpecialPowers.removePermission("browser", window.document);
    60   SpecialPowers.removePermission("embed-apps", window.document);
    62   SimpleTest.finish();
    63 });
    65 </script>
    66 </pre>
    67 </body>
    68 </html>

mercurial