author | Peter Van der Beken <peterv@propagandism.org> |
Wed, 13 Aug 2014 17:55:28 +0200 | |
changeset 221141 | acf50ee376c3d4e4e22ca2f5da3c663ba57c3591 |
parent 221140 | 55126a7a74479bfcf90d50cbb44503c00f6bbd8f |
child 221142 | e349895861e2c9a2b3f46e39605ca105ccab69f2 |
push id | 3979 |
push user | raliiev@mozilla.com |
push date | Mon, 13 Oct 2014 16:35:44 +0000 |
treeherder | mozilla-beta@30f2cc610691 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 1041808 |
milestone | 34.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/extensions/cookie/nsCookiePromptService.cpp +++ b/extensions/cookie/nsCookiePromptService.cpp @@ -8,16 +8,17 @@ #include "nsICookieAcceptDialog.h" #include "nsIDOMWindow.h" #include "nsPIDOMWindow.h" #include "nsIWindowWatcher.h" #include "nsIServiceManager.h" #include "nsString.h" #include "nsIDialogParamBlock.h" #include "nsIMutableArray.h" +#include "mozilla/dom/ScriptSettings.h" /**************************************************************** ************************ nsCookiePromptService ***************** ****************************************************************/ NS_IMPL_ISUPPORTS(nsCookiePromptService, nsICookiePromptService) nsCookiePromptService::nsCookiePromptService() { @@ -66,16 +67,21 @@ nsCookiePromptService::CookieDialog(nsID if (parent) { nsCOMPtr<nsPIDOMWindow> privateParent(do_QueryInterface(parent)); if (privateParent) privateParent = privateParent->GetPrivateRoot(); parent = do_QueryInterface(privateParent); } + // We're opening a chrome window and passing in a nsIDialogParamBlock. Setting + // the nsIDialogParamBlock as the .arguments property on the chrome window + // requires system principals on the stack, so we use an AutoNoJSAPI for that. + mozilla::dom::AutoNoJSAPI nojsapi; + // The cookie dialog will be modal for the root chrome window rather than the // tab containing the permission-requesting page. This removes confusion // about which monitor is displaying the dialog (see bug 470356), but also // avoids unwanted tab switches (see bug 405239). rv = wwatcher->OpenWindow(parent, "chrome://cookie/content/cookieAcceptDialog.xul", "_blank", "centerscreen,chrome,modal,titlebar", arguments, getter_AddRefs(dialog));
--- a/extensions/cookie/test/mochitest.ini +++ b/extensions/cookie/test/mochitest.ini @@ -33,8 +33,9 @@ support-files = [test_loadflags.html] [test_same_base_domain.html] [test_same_base_domain_2.html] [test_same_base_domain_3.html] [test_same_base_domain_4.html] [test_same_base_domain_5.html] [test_same_base_domain_6.html] [test_samedomain.html] +[test_bug1041808.html]
new file mode 100644 --- /dev/null +++ b/extensions/cookie/test/test_bug1041808.html @@ -0,0 +1,61 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1041808 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1041808</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + + /** Test for Bug 1041808 **/ + +SimpleTest.waitForExplicitFinish(); + +var dialogsOpened = 0; +var dialogsClosed = 0; +function dismissDialog(aSubject, aTopic, aData) +{ + if (aTopic == "domwindowopened") { + var win = SpecialPowers.wrap(aSubject); + win.addEventListener("pageshow", function() { + win.removeEventListener("pageshow", arguments.callee, false); + sendKey("RETURN", aSubject); + }, false); + ++dialogsOpened; + } else if (aTopic == "domwindowclosed") { + ++dialogsClosed; + } +} + +function runTest() +{ + SpecialPowers.Services.ww.registerNotification(dismissDialog); + document.cookie = "test1=testValue"; + document.cookie = "test2=testValue"; + document.cookie = "test3=testValue"; + SpecialPowers.Services.ww.unregisterNotification(dismissDialog); + is(dialogsOpened, 3, "Setting a cookie should have asked for permission"); + is(dialogsOpened - dialogsClosed, 0, + "Setting a cookie shouldn't have left any additional windows open"); + SimpleTest.finish(); +} + +SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy", 1]]}, + runTest); + + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1041808">Mozilla Bug 1041808</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +</pre> +</body> +</html>