dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial