toolkit/content/tests/browser/browser_bug982298.js

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.

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 Components.utils.import("resource://gre/modules/Timer.jsm");
michael@0 5
michael@0 6 const Ci = Components.interfaces;
michael@0 7
michael@0 8 let tab;
michael@0 9 let browser;
michael@0 10
michael@0 11 const scrollHtml =
michael@0 12 "<textarea id=\"textarea1\" row=2>Firefox\n\nFirefox\n\n\n\n\n\n\n\n\n\n" +
michael@0 13 "</textarea><a href=\"about:blank\">blank</a>";
michael@0 14
michael@0 15 const scrollTest =
michael@0 16 "var textarea = content.document.getElementById(\"textarea1\");" +
michael@0 17 "textarea.scrollTop = textarea.scrollHeight;" +
michael@0 18 "sendAsyncMessage(\"ScrollDone\", { });"
michael@0 19
michael@0 20 function test()
michael@0 21 {
michael@0 22 waitForExplicitFinish();
michael@0 23
michael@0 24 tab = gBrowser.addTab("data:text/html;base64," +
michael@0 25 btoa(scrollHtml));
michael@0 26 browser = gBrowser.getBrowserForTab(tab);
michael@0 27 gBrowser.selectedTab = tab;
michael@0 28
michael@0 29 browser.addEventListener("load", find, true);
michael@0 30 }
michael@0 31
michael@0 32 function find()
michael@0 33 {
michael@0 34 browser.removeEventListener("load", find, true);
michael@0 35 let listener = {
michael@0 36 onFindResult: function(aData) {
michael@0 37 browser.finder.removeResultListener(listener);
michael@0 38
michael@0 39 ok(aData.result == Ci.nsITypeAheadFind.FIND_FOUND, "should find string");
michael@0 40
michael@0 41 browser.messageManager.addMessageListener("ScrollDone",
michael@0 42 function f(aMsg) {
michael@0 43 browser.messageManager.removeMessageListener("ScrollDone", f);
michael@0 44 browser.loadURI("about:blank");
michael@0 45 browser.addEventListener("load", findAgain, true);
michael@0 46 });
michael@0 47
michael@0 48 // scroll textarea to bottom
michael@0 49 browser.messageManager.loadFrameScript("data:text/javascript;base64," +
michael@0 50 btoa(scrollTest), false);
michael@0 51
michael@0 52 },
michael@0 53 };
michael@0 54 browser.finder.addResultListener(listener);
michael@0 55 gFindBar.onFindCommand();
michael@0 56 EventUtils.sendString("F");
michael@0 57 }
michael@0 58
michael@0 59 function findAgain()
michael@0 60 {
michael@0 61 browser.removeEventListener("load", findAgain, true);
michael@0 62
michael@0 63 ok(browser.currentURI.spec == "about:blank", "cannot navigate to about:blank");
michael@0 64 let listener = {
michael@0 65 onFindResult: function(aData) {
michael@0 66 browser.finder.removeResultListener(listener);
michael@0 67 cleanup();
michael@0 68 },
michael@0 69 };
michael@0 70
michael@0 71 browser.finder.addResultListener(listener);
michael@0 72 // find again needs delay for crash test
michael@0 73 setTimeout(function() {
michael@0 74 // ignore exception if occured
michael@0 75 try {
michael@0 76 gFindBar.onFindAgainCommand(false);
michael@0 77 } catch (e) {
michael@0 78 }
michael@0 79 cleanup();
michael@0 80 }, 0);
michael@0 81 }
michael@0 82
michael@0 83 function cleanup()
michael@0 84 {
michael@0 85 gBrowser.removeTab(tab);
michael@0 86 finish();
michael@0 87 }

mercurial