1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/bug409624_window.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +<?xml version="1.0"?> 1.5 + 1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.7 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.9 + 1.10 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.11 + 1.12 +<window id="409624test" 1.13 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.14 + width="600" 1.15 + height="600" 1.16 + title="409624 test"> 1.17 + 1.18 + <script type="application/javascript" 1.19 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 1.20 + 1.21 + <script type="application/javascript"><![CDATA[ 1.22 + var gFindBar = null; 1.23 + var gBrowser; 1.24 + 1.25 + var imports = ["SimpleTest", "ok", "is"]; 1.26 + for each (var name in imports) { 1.27 + window[name] = window.opener.wrappedJSObject[name]; 1.28 + } 1.29 + 1.30 + function finish() { 1.31 + window.close(); 1.32 + SimpleTest.finish(); 1.33 + } 1.34 + 1.35 + function startTest() { 1.36 + gFindBar = document.getElementById("FindToolbar"); 1.37 + gBrowser = document.getElementById("content"); 1.38 + gBrowser.addEventListener("pageshow", onPageShow, false); 1.39 + gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />'); 1.40 + } 1.41 + 1.42 + function onPageShow() { 1.43 + gBrowser.removeEventListener("pageshow", onPageShow, false); 1.44 + gFindBar.clear(); 1.45 + let textbox = gFindBar.getElement("findbar-textbox"); 1.46 + 1.47 + // canClear / clear should work regardless of whether or not editor has 1.48 + // been lazily initialised yet 1.49 + ok(!gFindBar.canClear, "canClear property false when findbar empty"); 1.50 + textbox.value = "mozilla"; 1.51 + ok(gFindBar.canClear, "canClear property true when findbar value set without editor init"); 1.52 + gFindBar.clear(); 1.53 + is(textbox.value, '', "findbar input value cleared after clear() call without editor init"); 1.54 + ok(!gFindBar.canClear, "canClear property false after clear() call"); 1.55 + 1.56 + gFindBar.open(); 1.57 + let matchCaseCheckbox = gFindBar.getElement("find-case-sensitive"); 1.58 + if (!matchCaseCheckbox.hidden && matchCaseCheckbox.checked) 1.59 + matchCaseCheckbox.click(); 1.60 + ok(!matchCaseCheckbox.checked, "case-insensitivity correctly set"); 1.61 + 1.62 + // Simulate typical input 1.63 + textbox.focus(); 1.64 + gFindBar.clear(); 1.65 + sendChar("m"); 1.66 + ok(gFindBar.canClear, "canClear property true after input"); 1.67 + let preSelection = gBrowser.contentWindow.getSelection(); 1.68 + ok(!preSelection.isCollapsed, "Found item and selected range"); 1.69 + gFindBar.clear(); 1.70 + is(textbox.value, '', "findbar input value cleared after clear() call"); 1.71 + let postSelection = gBrowser.contentWindow.getSelection(); 1.72 + ok(postSelection.isCollapsed, "item found deselected after clear() call"); 1.73 + let fp = gFindBar.getElement("find-previous"); 1.74 + ok(fp.disabled, "find-previous button disabled after clear() call"); 1.75 + let fn = gFindBar.getElement("find-next"); 1.76 + ok(fn.disabled, "find-next button disabled after clear() call"); 1.77 + 1.78 + // Test status updated after a search for text not in page 1.79 + textbox.focus(); 1.80 + sendChar("x"); 1.81 + gFindBar.clear(); 1.82 + let ftext = gFindBar.getElement("find-status"); 1.83 + is(ftext.textContent, "", "status text disabled after clear() call"); 1.84 + 1.85 + // Test input empty with undo stack non-empty 1.86 + textbox.focus(); 1.87 + sendChar("m"); 1.88 + sendKey("BACK_SPACE"); 1.89 + ok(gFindBar.canClear, "canClear property true when undo available"); 1.90 + gFindBar.clear(); 1.91 + gFindBar.close(); 1.92 + 1.93 + finish(); 1.94 + } 1.95 + 1.96 + SimpleTest.waitForFocus(startTest, window); 1.97 + ]]></script> 1.98 + 1.99 + <browser type="content-primary" flex="1" id="content" src="about:blank"/> 1.100 + <findbar id="FindToolbar" browserid="content"/> 1.101 +</window>