зеркало из https://github.com/mozilla/gecko-dev.git
Bug 926033: add regression test. r=evilpie
This commit is contained in:
Родитель
6acafb0d9e
Коммит
1f9e9964af
|
@ -4,6 +4,7 @@
|
||||||
[browser_bug295977_autoscroll_overflow.js]
|
[browser_bug295977_autoscroll_overflow.js]
|
||||||
[browser_bug594509.js]
|
[browser_bug594509.js]
|
||||||
[browser_default_image_filename.js]
|
[browser_default_image_filename.js]
|
||||||
|
[browser_findbar.js]
|
||||||
[browser_input_file_tooltips.js]
|
[browser_input_file_tooltips.js]
|
||||||
[browser_keyevents_during_autoscrolling.js]
|
[browser_keyevents_during_autoscrolling.js]
|
||||||
[browser_save_resend_postdata.js]
|
[browser_save_resend_postdata.js]
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||||
|
"resource://gre/modules/commonjs/sdk/core/promise.js");
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||||
|
"resource://gre/modules/Task.jsm");
|
||||||
|
Components.utils.import("resource://gre/modules/Timer.jsm", this);
|
||||||
|
|
||||||
|
let gTabs = [];
|
||||||
|
|
||||||
|
registerCleanupFunction(function() {
|
||||||
|
for (let tab of gTabs) {
|
||||||
|
if (!tab)
|
||||||
|
continue;
|
||||||
|
gBrowser.removeTab(tab);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
Task.spawn(function() {
|
||||||
|
info("Check correct 'Phrase not found' on new tab");
|
||||||
|
|
||||||
|
// Create a tab to run the test.
|
||||||
|
yield promiseAboutHomeLoad();
|
||||||
|
|
||||||
|
// Search for the first word.
|
||||||
|
yield promiseFindFinished("--- THIS SHOULD NEVER MATCH ---", false);
|
||||||
|
let findbar = gBrowser.getFindBar();
|
||||||
|
is(findbar._findStatusDesc.textContent, findbar._notFoundStr,
|
||||||
|
"Findbar status text should be 'Phrase not found'");
|
||||||
|
|
||||||
|
// Create second tab.
|
||||||
|
yield promiseAboutHomeLoad();
|
||||||
|
|
||||||
|
// Search for a string that WILL be found, with 'Highlight All' on
|
||||||
|
yield promiseFindFinished("s", true);
|
||||||
|
ok(!gBrowser.getFindBar()._findStatusDesc.textContent,
|
||||||
|
"Findbar status should be empty");
|
||||||
|
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function promiseAboutHomeLoad() {
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
|
||||||
|
let tab = gBrowser.selectedTab = gBrowser.addTab("about:home");
|
||||||
|
gTabs.push(tab);
|
||||||
|
let browser = gBrowser.selectedBrowser;
|
||||||
|
browser.addEventListener("load", function listener() {
|
||||||
|
if (browser.currentURI.spec == "about:blank")
|
||||||
|
return;
|
||||||
|
info("Page loaded: " + browser.currentURI.spec);
|
||||||
|
browser.removeEventListener("load", listener, true);
|
||||||
|
|
||||||
|
deferred.resolve();
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function promiseFindFinished(searchText, highlightOn) {
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
|
||||||
|
let findbar = gBrowser.getFindBar();
|
||||||
|
findbar.startFind(findbar.FIND_NORMAL);
|
||||||
|
let highlightElement = findbar.getElement("highlight");
|
||||||
|
if (highlightElement.checked != highlightOn)
|
||||||
|
highlightElement.click();
|
||||||
|
executeSoon(() => {
|
||||||
|
findbar._findField.value = searchText;
|
||||||
|
|
||||||
|
let resultListener;
|
||||||
|
let findTimeout = setTimeout(() => foundOrTimedout(true), 2000);
|
||||||
|
let foundOrTimedout = function(timedOut) {
|
||||||
|
if (timedOut)
|
||||||
|
info("Result listener not called, timeout reached.");
|
||||||
|
clearTimeout(findTimeout);
|
||||||
|
findbar.browser.finder.removeResultListener(resultListener);
|
||||||
|
deferred.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
resultListener = {
|
||||||
|
onFindResult: foundOrTimedout
|
||||||
|
};
|
||||||
|
findbar.browser.finder.addResultListener(resultListener);
|
||||||
|
findbar._find();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче