Bug 1358815 - remove sync reflow from find bar initialization, r=jaws

This removes the sync reflow from almost all cases. The only case where we keep it is when a keypress
caught in content triggers a sync message to the parent process. We should clean this up in bug 1371523.

I've tried to fix the tests, but a lot of them seem to be disabled anyway...

MozReview-Commit-ID: 9k36p7q8MKy

--HG--
extra : rebase_source : 311ee41ba9456a5c5d58b81a0cfa999bcef0027e
This commit is contained in:
Gijs Kruitbosch 2018-03-12 14:01:44 +00:00
parent 51fd916771
commit d2ebbb38df
23 changed files with 197 additions and 124 deletions

View File

@ -44,16 +44,16 @@
<command id="View:FullScreen" oncommand="BrowserFullScreen();"/>
<command id="View:ReaderView" oncommand="ReaderParent.toggleReaderMode(event);"/>
<command id="cmd_find"
oncommand="gFindBar.onFindCommand();"
oncommand="gLazyFindCommand('onFindCommand')"
observes="isImage"/>
<command id="cmd_findAgain"
oncommand="gFindBar.onFindAgainCommand(false);"
oncommand="gLazyFindCommand('onFindAgainCommand', false)"
observes="isImage"/>
<command id="cmd_findPrevious"
oncommand="gFindBar.onFindAgainCommand(true);"
oncommand="gLazyFindCommand('onFindAgainCommand', true)"
observes="isImage"/>
#ifdef XP_MACOSX
<command id="cmd_findSelection" oncommand="gFindBar.onFindSelectionCommand();"/>
<command id="cmd_findSelection" oncommand="gLazyFindCommand('onFindSelectionCommand')"/>
#endif
<!-- work-around bug 392512 -->
<command id="Browser:AddBookmarkAs"

View File

@ -266,7 +266,7 @@ Object.defineProperty(this, "gFindBar", {
configurable: true,
enumerable: true,
get() {
return window.gBrowser.getFindBar();
return gBrowser.getCachedFindBar();
},
});
@ -274,10 +274,26 @@ Object.defineProperty(this, "gFindBarInitialized", {
configurable: true,
enumerable: true,
get() {
return window.gBrowser.isFindBarInitialized();
return gBrowser.isFindBarInitialized();
},
});
Object.defineProperty(this, "gFindBarPromise", {
configurable: true,
enumerable: true,
get() {
return gBrowser.getFindBar();
},
});
async function gLazyFindCommand(cmd, ...args) {
let fb = await gFindBarPromise;
// We could be closed by now, or the tab with XBL binding could have gone away:
if (fb && fb[cmd]) {
fb[cmd].apply(fb, args);
}
}
Object.defineProperty(this, "AddonManager", {
configurable: true,
enumerable: true,
@ -2069,7 +2085,7 @@ function HandleAppCommandEvent(evt) {
BrowserCloseTabOrWindow();
break;
case "Find":
gFindBar.onFindCommand();
gLazyFindCommand("onFindCommand");
break;
case "Help":
openHelpLink("firefox-help");
@ -3517,7 +3533,7 @@ var PrintPreviewListener = {
gBrowser.getNotificationBox().notificationsHidden = false;
if (this._chromeState.findOpen)
gFindBar.open();
gLazyFindCommand("open");
if (this._chromeState.globalNotificationsOpen)
document.getElementById("global-notificationbox").notificationsHidden = false;

View File

@ -477,20 +477,54 @@ window._gBrowser = {
return (aTab || this.selectedTab)._findBar != undefined;
},
getFindBar(aTab) {
if (!aTab)
aTab = this.selectedTab;
/**
* Get the already constructed findbar
*/
getCachedFindBar(aTab = this.selectedTab) {
return aTab._findBar;
},
if (aTab._findBar)
return aTab._findBar;
/**
* Get the findbar, and create it if it doesn't exist.
* @return the find bar (or null if the window or tab is closed/closing in the interim).
*/
async getFindBar(aTab = this.selectedTab) {
let findBar = this.getCachedFindBar(aTab);
if (findBar) {
return findBar;
}
// Avoid re-entrancy by caching the promise we're about to return.
if (!aTab._pendingFindBar) {
aTab._pendingFindBar = this._createFindBar(aTab);
}
return aTab._pendingFindBar;
},
/**
* Create a findbar instance.
* @param aTab the tab to create the find bar for.
* @param aForce Whether to force a sync flush to trigger XBL construction immediately.
* @return the created findbar, or null if the window or tab is closed/closing.
*/
async _createFindBar(aTab, aForce = false) {
let findBar = document.createElementNS(this._XUL_NS, "findbar");
let browser = this.getBrowserForTab(aTab);
let browserContainer = this.getBrowserContainer(browser);
browserContainer.appendChild(findBar);
// Force a style flush to ensure that our binding is attached.
findBar.clientTop;
if (aForce) {
// Force a style flush to ensure that our binding is attached.
// Remove after bug 1371523 makes more of this async.
findBar.clientTop;
} else {
await new Promise(r => requestAnimationFrame(r));
if (window.closed || aTab.closing) {
delete aTab._pendingFindBar;
return null;
}
}
delete aTab._pendingFindBar;
findBar.browser = browser;
findBar._findField.value = this._lastFindValue;
@ -1097,7 +1131,7 @@ window._gBrowser = {
oldBrowser._urlbarFocused = (gURLBar && gURLBar.focused);
if (this.isFindBarInitialized(oldTab)) {
let findBar = this.getFindBar(oldTab);
let findBar = this.getCachedFindBar(oldTab);
oldTab._findBarFocused = (!findBar.hidden &&
findBar._findField.getAttribute("focused") == "true");
}
@ -1672,7 +1706,7 @@ window._gBrowser = {
// If the findbar has been initialised, reset its browser reference.
if (this.isFindBarInitialized(tab)) {
this.getFindBar(tab).browser = aBrowser;
this.getCachedFindBar(tab).browser = aBrowser;
}
evt = document.createEvent("Events");
@ -3081,10 +3115,17 @@ window._gBrowser = {
let otherFindBar = aOtherTab._findBar;
if (otherFindBar &&
otherFindBar.findMode == otherFindBar.FIND_NORMAL) {
let ourFindBar = this.getFindBar(aOurTab);
ourFindBar._findField.value = otherFindBar._findField.value;
if (!otherFindBar.hidden)
ourFindBar.onFindCommand();
let oldValue = otherFindBar._findField.value;
let wasHidden = otherFindBar.hidden;
let ourFindBarPromise = this.getFindBar(aOurTab);
ourFindBarPromise.then(ourFindBar => {
if (!ourFindBar) {
return;
}
ourFindBar._findField.value = oldValue;
if (!wasHidden)
ourFindBar.onFindCommand();
});
}
// Finish tearing down the tab that's going away.
@ -3791,7 +3832,13 @@ window._gBrowser = {
}
if (shouldFastFind) {
// Make sure we return the result.
return this.getFindBar(tab).receiveMessage(aMessage);
// This needs sync initialization of the find bar, unfortunately.
// bug 1371523 tracks removing all of this.
// This returns a promise, so don't use the result...
this._createFindBar(tab, true);
// ... just grab the 'cached' version now we know it exists.
this.getCachedFindBar().receiveMessage(aMessage);
}
}
break;
@ -4489,7 +4536,7 @@ class TabProgressListener {
}
if (gBrowser.isFindBarInitialized(this.mTab)) {
let findBar = gBrowser.getFindBar(this.mTab);
let findBar = gBrowser.getCachedFindBar(this.mTab);
// Close the Find toolbar if we're in old-style TAF mode
if (findBar.findMode != findBar.FIND_NORMAL) {

View File

@ -42,19 +42,21 @@ function test() {
// Set up the first tab
gBrowser.selectedTab = tabs[0];
gBrowser.getFindBar().then(initialTest);
}
function initialTest() {
setFindString(texts[0]);
// Turn on highlight for testing bug 891638
gFindBar.getElement("highlight").checked = true;
// Make sure the second tab is correct, then set it up
gBrowser.selectedTab = tabs[1];
gBrowser.selectedTab.addEventListener("TabFindInitialized", continueTests1);
gBrowser.selectedTab.addEventListener("TabFindInitialized", continueTests1, {once: true});
// Initialize the findbar
gFindBar;
gBrowser.getFindBar();
}
function continueTests1() {
gBrowser.selectedTab.removeEventListener("TabFindInitialized",
continueTests1);
ok(true, "'TabFindInitialized' event properly dispatched!");
ok(gFindBar.hidden, "Second tab doesn't show find bar!");
gFindBar.open();
@ -97,6 +99,11 @@ function continueTests3() {
// Set up a third tab, no tests here
gBrowser.selectedTab = tabs[2];
gBrowser.selectedTab.addEventListener("TabFindInitialized", continueTests4, {once: true});
gBrowser.getFindBar();
}
function continueTests4() {
setFindString(texts[2]);
// Now we jump to the second, then first, and then fourth

View File

@ -21,7 +21,7 @@ add_task(async function() {
await SimpleTest.promiseFocus(newwindow);
ok(!newwindow.gFindBarInitialized, "find bar is not yet initialized");
let findBar = newwindow.gFindBar;
let findBar = await newwindow.gFindBarPromise;
await ContentTask.spawn(selectedBrowser, { }, async function() {
let elt = content.document.getElementById("h1");

View File

@ -6,24 +6,25 @@
const DUMMY_PAGE = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
function test() {
waitForExplicitFinish();
/**
* This test checks that if you search for something on one tab, then close
* that tab and have the find bar open on the next tab you get switched to,
* closing the find bar in that tab works without exceptions.
*/
add_task(async function test_bug749738() {
// Open find bar on initial tab.
await gFindBarPromise;
let tab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedTab = tab;
BrowserTestUtils.loadURI(tab.linkedBrowser, DUMMY_PAGE);
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
await BrowserTestUtils.withNewTab(DUMMY_PAGE, async function() {
await gFindBarPromise;
gFindBar.onFindCommand();
EventUtils.sendString("Dummy");
gBrowser.removeTab(tab);
try {
gFindBar.close();
ok(true, "findbar.close should not throw an exception");
} catch (e) {
ok(false, "findbar.close threw exception: " + e);
}
finish();
});
}
try {
gFindBar.close();
ok(true, "findbar.close should not throw an exception");
} catch (e) {
ok(false, "findbar.close threw exception: " + e);
}
});

View File

@ -16,6 +16,7 @@ add_task(async function findbar_test() {
"browser/base/content/test/general/test_bug628179.html");
await promise;
await gFindBarPromise;
gFindBar.open();
await new ContentTask.spawn(newTab.linkedBrowser, null, async function() {

View File

@ -2,79 +2,60 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var gTab = null;
function load(url, cb) {
gTab = BrowserTestUtils.addTab(gBrowser, url);
gBrowser.addEventListener("load", function listener(event) {
if (event.target.location != url)
return;
gBrowser.removeEventListener("load", listener, true);
// Trigger onLocationChange by switching tabs.
gBrowser.selectedTab = gTab;
cb();
}, true);
}
function test() {
waitForExplicitFinish();
ok(gFindBar.hidden, "Find bar should not be visible by default");
add_task(async function findBarDisabledOnSomePages() {
ok(!gFindBar || gFindBar.hidden, "Find bar should not be visible by default");
let findbarOpenedPromise = BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "TabFindInitialized");
document.documentElement.focus();
// Open the Find bar before we navigate to pages that shouldn't have it.
EventUtils.synthesizeKey("f", { accelKey: true });
await findbarOpenedPromise;
ok(!gFindBar.hidden, "Find bar should be visible");
nextTest();
}
let urls = [
"about:config",
"about:addons",
];
var urls = [
"about:config",
"about:addons",
];
function nextTest() {
let url = urls.shift();
if (url) {
testFindDisabled(url, nextTest);
} else {
// Make sure the find bar is re-enabled after disabled page is closed.
testFindEnabled("about:blank", function() {
EventUtils.synthesizeKey("KEY_Escape");
ok(gFindBar.hidden, "Find bar should now be hidden");
finish();
});
for (let url of urls) {
await testFindDisabled(url);
}
}
function testFindDisabled(url, cb) {
load(url, function() {
ok(gFindBar.hidden, "Find bar should not be visible");
EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
ok(gFindBar.hidden, "Find bar should not be visible");
// Make sure the find bar is re-enabled after disabled page is closed.
await testFindEnabled("about:about");
gFindBar.close();
ok(gFindBar.hidden, "Find bar should now be hidden");
});
function testFindDisabled(url) {
return BrowserTestUtils.withNewTab(url, async function(browser) {
let waitForFindBar = async () => {
await new Promise(r => requestAnimationFrame(r));
await new Promise(r => Services.tm.dispatchToMainThread(r));
};
ok(!gFindBar || gFindBar.hidden, "Find bar should not be visible at the start");
await BrowserTestUtils.synthesizeKey("/", {}, browser);
await waitForFindBar();
ok(!gFindBar || gFindBar.hidden, "Find bar should not be visible after fast find");
EventUtils.synthesizeKey("f", {accelKey: true});
ok(gFindBar.hidden, "Find bar should not be visible");
await waitForFindBar();
ok(!gFindBar || gFindBar.hidden, "Find bar should not be visible after find command");
ok(document.getElementById("cmd_find").getAttribute("disabled"),
"Find command should be disabled");
gBrowser.removeTab(gTab);
cb();
});
}
function testFindEnabled(url, cb) {
load(url, function() {
async function testFindEnabled(url) {
return BrowserTestUtils.withNewTab(url, async function(browser) {
ok(!document.getElementById("cmd_find").getAttribute("disabled"),
"Find command should not be disabled");
// Open Find bar and then close it.
let findbarOpenedPromise = BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "TabFindInitialized");
EventUtils.synthesizeKey("f", { accelKey: true });
await findbarOpenedPromise;
ok(!gFindBar.hidden, "Find bar should be visible again");
EventUtils.synthesizeKey("KEY_Escape");
ok(gFindBar.hidden, "Find bar should now be hidden");
gBrowser.removeTab(gTab);
cb();
});
}

View File

@ -22,6 +22,7 @@ add_task(async function test() {
// Sanitize now so we can test the baseline point.
await Sanitizer.sanitize(["formdata"]);
await gFindBarPromise;
ok(!gFindBar.hasTransactions, "pre-test baseline for sanitizer");
gFindBar.getElement("findbar-textbox").value = "m";

View File

@ -181,8 +181,8 @@ const CustomizableWidgets = [
tooltiptext: "find-button.tooltiptext3",
onCommand(aEvent) {
let win = aEvent.target.ownerGlobal;
if (win.gFindBar) {
win.gFindBar.onFindCommand();
if (win.gLazyFindCommand) {
win.gLazyFindCommand("onFindCommand");
}
}
}, {

View File

@ -17,7 +17,11 @@ add_task(async function() {
let findButton = document.getElementById("find-button");
ok(findButton, "Find button exists in Panel Menu");
let findBarPromise = gBrowser.isFindBarInitialized() ?
null : BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "TabFindInitialized");
findButton.click();
await findBarPromise;
ok(!gFindBar.hasAttribute("hidden"), "Findbar opened successfully");
// close find bar

View File

@ -94,12 +94,15 @@ add_task(async function testEnterKeyBehaviors() {
EventUtils.synthesizeKey("KEY_ArrowUp");
focusedElement = document.commandDispatcher.focusedElement;
}
let findBarPromise = gBrowser.isFindBarInitialized() ?
null : BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "TabFindInitialized");
Assert.equal(focusedElement.id, kFindButtonId, "Find button should be selected");
promise = promisePanelHidden(window);
EventUtils.synthesizeKey("KEY_Enter");
await promise;
await findBarPromise;
Assert.ok(!gFindBar.hidden, "Findbar should have opened");
gFindBar.close();
});

View File

@ -16,7 +16,10 @@ var tooltip = document.getElementById("UITourTooltip");
function test() {
registerCleanupFunction(() => {
// Close the find bar in case it's open in the remaining tab
gBrowser.getFindBar(gBrowser.selectedTab).close();
let findBar = gBrowser.getCachedFindBar(gBrowser.selectedTab);
if (findBar) {
findBar.close();
}
});
UITourTest();
}

View File

@ -494,7 +494,7 @@ var Sanitizer = {
}
for (let tab of tabBrowser.tabs) {
if (tabBrowser.isFindBarInitialized(tab))
tabBrowser.getFindBar(tab).clear();
tabBrowser.getCachedFindBar(tab).clear();
}
// Clear any saved find value
tabBrowser._lastFindValue = "";

View File

@ -188,7 +188,7 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) {
// Swapping browsers disconnects the find bar UI from the browser.
// If the find bar has been initialized, reconnect it.
if (gBrowser.isFindBarInitialized(tab)) {
let findBar = gBrowser.getFindBar(tab);
let findBar = gBrowser.getCachedFindBar(tab);
findBar.browser = tab.linkedBrowser;
if (!findBar.hidden) {
// Force the find bar to activate again, restoring the search string.
@ -253,7 +253,7 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) {
// Swapping browsers disconnects the find bar UI from the browser.
// If the find bar has been initialized, reconnect it.
if (gBrowser.isFindBarInitialized(tab)) {
let findBar = gBrowser.getFindBar(tab);
let findBar = gBrowser.getCachedFindBar(tab);
findBar.browser = tab.linkedBrowser;
if (!findBar.hidden) {
// Force the find bar to activate again, restoring the search string.

View File

@ -26,6 +26,11 @@ add_task(async function() {
// browser has dispatched its return message with the prefill value for
// the findbar, which essentially nulls these tests.
// The parent-side of the sidebar initialization is also async, so we do
// need to wait for that. We verify a bit further down that _startFindDeferred
// hasn't been resolved yet.
await gFindBarPromise;
let findBar = gFindBar;
is(findBar._findField.value, "", "findbar is empty");

View File

@ -135,6 +135,7 @@ function findAgainAndWait() {
}
async function openFindBarAndWait() {
await gFindBarPromise;
let awaitTransitionEnd = BrowserTestUtils.waitForEvent(gFindBar, "transitionend");
gFindBar.open();
await awaitTransitionEnd;

View File

@ -20,6 +20,7 @@ add_task(async function() {
info("about to add results listener, open find bar, and send 'F' string");
browser.finder.addResultListener(listener);
});
await gFindBarPromise;
gFindBar.onFindCommand();
EventUtils.sendString("F");
info("added result listener and sent string 'F'");

View File

@ -17,7 +17,7 @@ add_task(async function test_hotkey_event_propagation() {
// Opening new tab
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI);
let browser = gBrowser.getBrowserForTab(tab);
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
// Pressing these keys open the findbar.
const HOTKEYS = ["/", "'"];
@ -64,7 +64,7 @@ add_task(async function test_not_found() {
// Search for the first word.
await promiseFindFinished("--- THIS SHOULD NEVER MATCH ---", false);
let findbar = gBrowser.getFindBar();
let findbar = gBrowser.getCachedFindBar();
is(findbar._findStatusDesc.textContent, findbar._notFoundStr,
"Findbar status text should be 'Phrase not found'");
@ -76,7 +76,7 @@ add_task(async function test_found() {
// Search for a string that WILL be found, with 'Highlight All' on
await promiseFindFinished("S", true);
ok(!gBrowser.getFindBar()._findStatusDesc.textContent,
ok(!gBrowser.getCachedFindBar()._findStatusDesc.textContent,
"Findbar status should be empty");
gBrowser.removeTab(tab);
@ -86,10 +86,10 @@ add_task(async function test_found() {
// new tab find bar.
add_task(async function test_tabwise_case_sensitive() {
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI);
let findbar1 = gBrowser.getFindBar();
let findbar1 = await gBrowser.getFindBar();
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI);
let findbar2 = gBrowser.getFindBar();
let findbar2 = await gBrowser.getFindBar();
// Toggle case sensitivity for first findbar
findbar1.getElement("find-case-sensitive").click();
@ -130,7 +130,7 @@ add_task(async function test_reinitialization_at_remoteness_change() {
// Load a remote page and trigger findbar construction.
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI);
let browser = gBrowser.getBrowserForTab(tab);
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
// Findbar should operate normally.
await promiseFindFinished("z", false);
@ -173,6 +173,7 @@ add_task(async function() {
ok(!gFindBarInitialized, "findbar isn't initialized yet");
await gFindBarPromise;
let findBar = gFindBar;
let initialValue = findBar._findField.value;
@ -199,9 +200,9 @@ add_task(async function() {
});
function promiseFindFinished(searchText, highlightOn) {
return new Promise(resolve => {
return new Promise(async (resolve) => {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
findbar.startFind(findbar.FIND_NORMAL);
let highlightElement = findbar.getElement("highlight");
if (highlightElement.checked != highlightOn)

View File

@ -3,7 +3,7 @@ const DESIGNMODE_PAGE = "data:text/html,<body onload='document.designMode=\"on\"
const HOTKEYS = ["/", "'"];
async function test_hotkeys(browser, expected) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
for (let key of HOTKEYS) {
is(findbar.hidden, true, "findbar is hidden");
await BrowserTestUtils.sendChar(key, gBrowser.selectedBrowser);

View File

@ -420,7 +420,7 @@
return;
this._destroyed = true;
if (this.browser.finder)
if (this.browser && this.browser.finder)
this.browser.finder.destroy();
this.browser = null;

View File

@ -49,7 +49,7 @@ add_task(async function testModalResults() {
]);
let url = kFixtureBaseURL + "file_FinderSample.html";
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
for (let [word, expectedResult] of tests) {
await promiseOpenFindbar(findbar);
@ -76,7 +76,7 @@ add_task(async function testModalResults() {
add_task(async function testModalSwitching() {
let url = kFixtureBaseURL + "file_FinderSample.html";
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
Assert.ok(!findbar.hidden, "Findbar should be open now.");
@ -113,7 +113,7 @@ add_task(async function testModalSwitching() {
add_task(async function testDarkPageDetection() {
let url = kFixtureBaseURL + "file_FinderSample.html";
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
@ -134,7 +134,7 @@ add_task(async function testDarkPageDetection() {
});
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
@ -172,7 +172,7 @@ add_task(async function testDarkPageDetection() {
add_task(async function testHighlightAllToggle() {
let url = kFixtureBaseURL + "file_FinderSample.html";
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
@ -216,7 +216,7 @@ add_task(async function testXMLDocument() {
<Error>Error</Error>
</result>`);
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
@ -238,7 +238,7 @@ add_task(async function testHideOnLocationChange() {
let url = kFixtureBaseURL + "file_FinderSample.html";
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
let browser = tab.linkedBrowser;
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
@ -267,7 +267,7 @@ add_task(async function testHideOnLocationChange() {
add_task(async function testHideOnClear() {
let url = kFixtureBaseURL + "file_FinderSample.html";
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
let word = "Roland";
@ -299,7 +299,7 @@ add_task(async function testRectsAndTexts() {
"Here are a lot of words Please use find to highlight some words that wrap" +
" across a line boundary and see what happens.</div>");
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
let word = "words please use find to";
@ -322,7 +322,7 @@ add_task(async function testRectsAndTexts() {
add_task(async function testTooLargeToggle() {
let url = kFixtureBaseURL + "file_FinderSample.html";
await BrowserTestUtils.withNewTab(url, async function(browser) {
let findbar = gBrowser.getFindBar();
let findbar = await gBrowser.getFindBar();
await promiseOpenFindbar(findbar);
await ContentTask.spawn(browser, null, async function() {

View File

@ -25,7 +25,8 @@ function compareLists(list1, list2, kind) {
is(String(list1), String(list2), `${kind} URLs correct`);
}
function promiseOpenFindbar(findbar) {
async function promiseOpenFindbar(findbar) {
await gBrowser.getFindBar();
findbar.onFindCommand();
return gFindBar._startFindDeferred && gFindBar._startFindDeferred.promise;
}