зеркало из https://github.com/mozilla/gecko-dev.git
Bug 567306 - Find command(ctrl+F) does not start looking for it with a selected text on the actual page. r=gavin.
This commit is contained in:
Родитель
9e8fb2c03a
Коммит
65635f66c4
|
@ -113,7 +113,6 @@ var gFindBarInitialized = false;
|
|||
XPCOMUtils.defineLazyGetter(window, "gFindBar", function() {
|
||||
let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
let findbar = document.createElementNS(XULNS, "findbar");
|
||||
findbar.setAttribute("browserid", "content");
|
||||
findbar.id = "FindToolbar";
|
||||
|
||||
let browserBottomBox = document.getElementById("browser-bottombox");
|
||||
|
@ -121,6 +120,7 @@ XPCOMUtils.defineLazyGetter(window, "gFindBar", function() {
|
|||
|
||||
// Force a style flush to ensure that our binding is attached.
|
||||
findbar.clientTop;
|
||||
findbar.browser = gBrowser;
|
||||
window.gFindBarInitialized = true;
|
||||
return findbar;
|
||||
});
|
||||
|
|
|
@ -83,6 +83,7 @@ _TEST_FILES = \
|
|||
|
||||
_BROWSER_FILES = \
|
||||
browser_typeAheadFind.js \
|
||||
browser_bug567306.js \
|
||||
browser_NetworkPrioritizer.js \
|
||||
browser_allTabsPanel.js \
|
||||
browser_alltabslistener.js \
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let testWindow = null;
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
testWindow = OpenBrowserWindow();
|
||||
testWindow.addEventListener("load", function() {
|
||||
testWindow.removeEventListener("load", arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
ok(true, "Load listener called");
|
||||
testWindow.gBrowser.selectedBrowser.addEventListener("pageshow", function () {
|
||||
ok(true, "Pageshow listener called");
|
||||
testWindow.gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee, false);
|
||||
waitForFocus(onFocus, testWindow.content);
|
||||
}, true);
|
||||
testWindow.content.location = "data:text/html,<h1 id='h1'>Select Me</h1>";
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function selectText() {
|
||||
let elt = testWindow.content.document.getElementById("h1");
|
||||
let selection = testWindow.content.getSelection();
|
||||
let range = testWindow.content.document.createRange();
|
||||
range.setStart(elt, 0);
|
||||
range.setEnd(elt, 1);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
|
||||
|
||||
function onFocus() {
|
||||
ok(!testWindow.gFindBarInitialized, "find bar is not yet initialized");
|
||||
selectText();
|
||||
testWindow.gFindBar.onFindCommand();
|
||||
ok(testWindow.gFindBar._findField.value == "Select Me", "Findbar is initialized with selection");
|
||||
testWindow.gFindBar.close();
|
||||
testWindow.close();
|
||||
finish();
|
||||
}
|
|
@ -1,60 +1,30 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is typeaheadfind test code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gavin Sharp <gavin@gavinsharp.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let testWindow = null;
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
ok(!gFindBarInitialized, "find bar is not yet initialized");
|
||||
|
||||
let tab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tab;
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
testWindow = OpenBrowserWindow();
|
||||
testWindow.addEventListener("load", function() {
|
||||
testWindow.removeEventListener("load", arguments.callee, true);
|
||||
ok(true, "Load listener called");
|
||||
waitForFocus(onFocus, content);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html,<h1>A Page</h1>";
|
||||
executeSoon(function() {
|
||||
ok(!testWindow.gFindBarInitialized, "find bar is not yet initialized");
|
||||
testWindow.gBrowser.selectedBrowser.addEventListener("pageshow", function () {
|
||||
ok(true, "Pageshow listener called");
|
||||
testWindow.gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee, false);
|
||||
waitForFocus(onFocus, testWindow.content);
|
||||
}, true);
|
||||
testWindow.content.location = "data:text/html,<h1>A Page</h1>";
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function onFocus() {
|
||||
EventUtils.synthesizeKey("/", {});
|
||||
ok(gFindBarInitialized, "find bar is now initialized");
|
||||
gFindBar.close();
|
||||
gBrowser.removeCurrentTab();
|
||||
ok(testWindow.gFindBarInitialized, "find bar is now initialized");
|
||||
testWindow.gFindBar.close();
|
||||
testWindow.close();
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -404,7 +404,8 @@
|
|||
|
||||
// Make sure the FAYT keypress listener is attached by initializing the
|
||||
// browser property
|
||||
setTimeout(function(aSelf) { aSelf.browser = aSelf.browser; }, 0, this);
|
||||
if (this.getAttribute("browserid"))
|
||||
setTimeout(function(aSelf) { aSelf.browser = aSelf.browser; }, 0, this);
|
||||
]]></constructor>
|
||||
|
||||
<destructor><![CDATA[
|
||||
|
|
Загрузка…
Ссылка в новой задаче