1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* Any copyright is dedicated to the public domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Bug 806127 - Test that cookies set by <iframe mozbrowser> are not considered 1.8 +// third-party. 1.9 +"use strict"; 1.10 + 1.11 +SimpleTest.waitForExplicitFinish(); 1.12 +browserElementTestHelpers.setEnabledPref(true); 1.13 +browserElementTestHelpers.addPermission(); 1.14 + 1.15 +function runTest() { 1.16 + const innerPage = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html'; 1.17 + 1.18 + var iframe = document.createElement('iframe'); 1.19 + SpecialPowers.wrap(iframe).mozbrowser = true; 1.20 + 1.21 + iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { 1.22 + if (e.detail.message == 'next') { 1.23 + iframe.src = innerPage + '?step=2'; 1.24 + return; 1.25 + } 1.26 + 1.27 + if (e.detail.message.startsWith('success:')) { 1.28 + ok(true, e.detail.message); 1.29 + return; 1.30 + } 1.31 + 1.32 + if (e.detail.message.startsWith('failure:')) { 1.33 + ok(false, e.detail.message); 1.34 + return; 1.35 + } 1.36 + 1.37 + if (e.detail.message == 'finish') { 1.38 + SimpleTest.finish(); 1.39 + } 1.40 + }); 1.41 + 1.42 + // innerPage will set a cookie and then alert('next'). We'll load 1.43 + // innerPage?step=2. That page will check that the cooke exists (despite the 1.44 + // fact that we've disabled third-party cookies) and alert('success:') or 1.45 + // alert('failure:'), as appropriate. Finally, the page will 1.46 + // alert('finish'); 1.47 + iframe.src = innerPage; 1.48 + document.body.appendChild(iframe); 1.49 +} 1.50 + 1.51 +// Disable third-party cookies for this test. 1.52 +addEventListener('testready', function() { 1.53 + SpecialPowers.pushPrefEnv({'set': [['network.cookie.cookieBehavior', 1]]}, runTest); 1.54 +});