mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 567306 - Only set the Find bar's browser property if its browser ID is valid.
r=gavin a=blocking
This commit is contained in:
parent
8a712260ec
commit
c0d0afb9d7
@ -115,7 +115,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");
|
||||
@ -123,6 +122,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;
|
||||
});
|
||||
|
@ -146,6 +146,7 @@ _BROWSER_FILES = \
|
||||
browser_bug562649.js \
|
||||
browser_bug563588.js \
|
||||
browser_bug565575.js \
|
||||
browser_bug567306.js \
|
||||
browser_zbug569342.js \
|
||||
browser_bug575561.js \
|
||||
browser_bug577121.js \
|
||||
|
40
browser/base/content/test/browser_bug567306.js
Normal file
40
browser/base/content/test/browser_bug567306.js
Normal file
@ -0,0 +1,40 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let Ci = Components.interfaces;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
let tab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tab;
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
ok(true, "Load listener called");
|
||||
waitForFocus(onFocus, content);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html,<h1 id='h1'>Select Me</h1>";
|
||||
}
|
||||
|
||||
function selectText() {
|
||||
let elt = content.document.getElementById("h1");
|
||||
let selection = content.getSelection();
|
||||
let range = content.document.createRange();
|
||||
range.setStart(elt, 0);
|
||||
range.setEnd(elt, 1);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
|
||||
|
||||
function onFocus() {
|
||||
ok(!gFindBarInitialized, "find bar is not yet initialized");
|
||||
selectText();
|
||||
gFindBar.onFindCommand();
|
||||
ok(gFindBar._findField.value == "Select Me", "Findbar is initialized with selection");
|
||||
gFindBar.close();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
@ -35,25 +35,32 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
let testWindow = null;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
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() {
|
||||
ok(true, "Load listener called");
|
||||
waitForFocus(onFocus, content);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html,<h1>A Page</h1>";
|
||||
executeSoon(function() {
|
||||
let selectedBrowser = testWindow.gBrowser.selectedBrowser;
|
||||
selectedBrowser.addEventListener("pageshow", function() {
|
||||
selectedBrowser.removeEventListener("pageshow", arguments.callee,
|
||||
false);
|
||||
ok(true, "pageshow listener called");
|
||||
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();
|
||||
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[
|
||||
|
Loading…
Reference in New Issue
Block a user