dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* Any copyright is dedicated to the public domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // Bug 806127 - Test that cookies set by <iframe mozbrowser> are not considered
     5 // third-party.
     6 "use strict";
     8 SimpleTest.waitForExplicitFinish();
     9 browserElementTestHelpers.setEnabledPref(true);
    10 browserElementTestHelpers.addPermission();
    12 function runTest() {
    13   const innerPage = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html';
    15   var iframe = document.createElement('iframe');
    16   SpecialPowers.wrap(iframe).mozbrowser = true;
    18   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
    19     if (e.detail.message == 'next') {
    20       iframe.src = innerPage + '?step=2';
    21       return;
    22     }
    24     if (e.detail.message.startsWith('success:')) {
    25       ok(true, e.detail.message);
    26       return;
    27     }
    29     if (e.detail.message.startsWith('failure:')) {
    30       ok(false, e.detail.message);
    31       return;
    32     }
    34     if (e.detail.message == 'finish') {
    35       SimpleTest.finish();
    36     }
    37   });
    39   // innerPage will set a cookie and then alert('next').  We'll load
    40   // innerPage?step=2.  That page will check that the cooke exists (despite the
    41   // fact that we've disabled third-party cookies) and alert('success:') or
    42   // alert('failure:'), as appropriate.  Finally, the page will
    43   // alert('finish');
    44   iframe.src = innerPage;
    45   document.body.appendChild(iframe);
    46 }
    48 // Disable third-party cookies for this test.
    49 addEventListener('testready', function() {
    50   SpecialPowers.pushPrefEnv({'set': [['network.cookie.cookieBehavior', 1]]}, runTest);
    51 });

mercurial