toolkit/content/tests/chrome/bug409624_window.xul

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 <?xml version="1.0"?>
michael@0 2
michael@0 3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 6
michael@0 7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 8
michael@0 9 <window id="409624test"
michael@0 10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 11 width="600"
michael@0 12 height="600"
michael@0 13 title="409624 test">
michael@0 14
michael@0 15 <script type="application/javascript"
michael@0 16 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
michael@0 17
michael@0 18 <script type="application/javascript"><![CDATA[
michael@0 19 var gFindBar = null;
michael@0 20 var gBrowser;
michael@0 21
michael@0 22 var imports = ["SimpleTest", "ok", "is"];
michael@0 23 for each (var name in imports) {
michael@0 24 window[name] = window.opener.wrappedJSObject[name];
michael@0 25 }
michael@0 26
michael@0 27 function finish() {
michael@0 28 window.close();
michael@0 29 SimpleTest.finish();
michael@0 30 }
michael@0 31
michael@0 32 function startTest() {
michael@0 33 gFindBar = document.getElementById("FindToolbar");
michael@0 34 gBrowser = document.getElementById("content");
michael@0 35 gBrowser.addEventListener("pageshow", onPageShow, false);
michael@0 36 gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
michael@0 37 }
michael@0 38
michael@0 39 function onPageShow() {
michael@0 40 gBrowser.removeEventListener("pageshow", onPageShow, false);
michael@0 41 gFindBar.clear();
michael@0 42 let textbox = gFindBar.getElement("findbar-textbox");
michael@0 43
michael@0 44 // canClear / clear should work regardless of whether or not editor has
michael@0 45 // been lazily initialised yet
michael@0 46 ok(!gFindBar.canClear, "canClear property false when findbar empty");
michael@0 47 textbox.value = "mozilla";
michael@0 48 ok(gFindBar.canClear, "canClear property true when findbar value set without editor init");
michael@0 49 gFindBar.clear();
michael@0 50 is(textbox.value, '', "findbar input value cleared after clear() call without editor init");
michael@0 51 ok(!gFindBar.canClear, "canClear property false after clear() call");
michael@0 52
michael@0 53 gFindBar.open();
michael@0 54 let matchCaseCheckbox = gFindBar.getElement("find-case-sensitive");
michael@0 55 if (!matchCaseCheckbox.hidden && matchCaseCheckbox.checked)
michael@0 56 matchCaseCheckbox.click();
michael@0 57 ok(!matchCaseCheckbox.checked, "case-insensitivity correctly set");
michael@0 58
michael@0 59 // Simulate typical input
michael@0 60 textbox.focus();
michael@0 61 gFindBar.clear();
michael@0 62 sendChar("m");
michael@0 63 ok(gFindBar.canClear, "canClear property true after input");
michael@0 64 let preSelection = gBrowser.contentWindow.getSelection();
michael@0 65 ok(!preSelection.isCollapsed, "Found item and selected range");
michael@0 66 gFindBar.clear();
michael@0 67 is(textbox.value, '', "findbar input value cleared after clear() call");
michael@0 68 let postSelection = gBrowser.contentWindow.getSelection();
michael@0 69 ok(postSelection.isCollapsed, "item found deselected after clear() call");
michael@0 70 let fp = gFindBar.getElement("find-previous");
michael@0 71 ok(fp.disabled, "find-previous button disabled after clear() call");
michael@0 72 let fn = gFindBar.getElement("find-next");
michael@0 73 ok(fn.disabled, "find-next button disabled after clear() call");
michael@0 74
michael@0 75 // Test status updated after a search for text not in page
michael@0 76 textbox.focus();
michael@0 77 sendChar("x");
michael@0 78 gFindBar.clear();
michael@0 79 let ftext = gFindBar.getElement("find-status");
michael@0 80 is(ftext.textContent, "", "status text disabled after clear() call");
michael@0 81
michael@0 82 // Test input empty with undo stack non-empty
michael@0 83 textbox.focus();
michael@0 84 sendChar("m");
michael@0 85 sendKey("BACK_SPACE");
michael@0 86 ok(gFindBar.canClear, "canClear property true when undo available");
michael@0 87 gFindBar.clear();
michael@0 88 gFindBar.close();
michael@0 89
michael@0 90 finish();
michael@0 91 }
michael@0 92
michael@0 93 SimpleTest.waitForFocus(startTest, window);
michael@0 94 ]]></script>
michael@0 95
michael@0 96 <browser type="content-primary" flex="1" id="content" src="about:blank"/>
michael@0 97 <findbar id="FindToolbar" browserid="content"/>
michael@0 98 </window>

mercurial