зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1283042 - add a test for highlighting XML documents; needed to fix up highlightFinished notifications. r=jaws
MozReview-Commit-ID: HKw51diGOBm
This commit is contained in:
Родитель
64c8ce2feb
Коммит
ef97f74f53
|
@ -238,8 +238,7 @@ Finder.prototype = {
|
|||
},
|
||||
|
||||
highlight: Task.async(function* (aHighlight, aWord, aLinksOnly) {
|
||||
let found = yield this.highlighter.highlight(aHighlight, aWord, null, aLinksOnly);
|
||||
this.highlighter.notifyFinished({ highlight: aHighlight, found });
|
||||
yield this.highlighter.highlight(aHighlight, aWord, null, aLinksOnly);
|
||||
}),
|
||||
|
||||
getInitialSelection: function() {
|
||||
|
|
|
@ -224,6 +224,8 @@ FinderHighlighter.prototype = {
|
|||
this._found = true;
|
||||
}
|
||||
|
||||
this.notifyFinished({ highlight, found: this._found });
|
||||
|
||||
return this._found;
|
||||
}),
|
||||
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
Cu.import("resource://testing-common/BrowserTestUtils.jsm", this);
|
||||
Cu.import("resource://testing-common/ContentTask.jsm", this);
|
||||
Cu.import("resource://gre/modules/Promise.jsm", this);
|
||||
Cu.import("resource://gre/modules/Services.jsm", this);
|
||||
Cu.import("resource://gre/modules/Task.jsm", this);
|
||||
Cu.import("resource://gre/modules/Timer.jsm", this);
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
const kHighlightAllPref = "findbar.highlightAll";
|
||||
const kPrefModalHighlight = "findbar.modalHighlight";
|
||||
const kFixtureBaseURL = "https://example.com/browser/toolkit/modules/tests/browser/";
|
||||
const kIteratorTimeout = Services.prefs.getIntPref("findbar.iteratorTimeout");
|
||||
|
||||
function promiseOpenFindbar(findbar) {
|
||||
findbar.onFindCommand()
|
||||
|
@ -155,8 +158,8 @@ add_task(function* testModalResults() {
|
|||
}],
|
||||
["o", {
|
||||
rectCount: 492,
|
||||
insertCalls: [1, 4],
|
||||
removeCalls: [1, 3]
|
||||
insertCalls: [1, 5],
|
||||
removeCalls: [1, 4]
|
||||
}]
|
||||
]);
|
||||
let url = kFixtureBaseURL + "file_FinderSample.html";
|
||||
|
@ -167,6 +170,7 @@ add_task(function* testModalResults() {
|
|||
yield promiseOpenFindbar(findbar);
|
||||
Assert.ok(!findbar.hidden, "Findbar should be open now.");
|
||||
|
||||
yield new Promise(resolve => setTimeout(resolve, kIteratorTimeout));
|
||||
let promise = promiseTestHighlighterOutput(browser, word, expectedResult);
|
||||
yield promiseEnterStringIntoFindField(findbar, word);
|
||||
yield promise;
|
||||
|
@ -311,3 +315,28 @@ add_task(function* testHighlightAllToggle() {
|
|||
yield promise;
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* testXMLDocument() {
|
||||
let url = "data:text/xml;charset=utf-8," + encodeURIComponent(`<?xml version="1.0"?>
|
||||
<result>
|
||||
<Title>Example</Title>
|
||||
<Error>Error</Error>
|
||||
</result>`);
|
||||
yield BrowserTestUtils.withNewTab(url, function* (browser) {
|
||||
let findbar = gBrowser.getFindBar();
|
||||
|
||||
yield promiseOpenFindbar(findbar);
|
||||
|
||||
let word = "Example";
|
||||
let expectedResult = {
|
||||
rectCount: 0,
|
||||
insertCalls: [1, 4],
|
||||
removeCalls: [1, 2]
|
||||
};
|
||||
let promise = promiseTestHighlighterOutput(browser, word, expectedResult);
|
||||
yield promiseEnterStringIntoFindField(findbar, word);
|
||||
yield promise;
|
||||
|
||||
findbar.close(true);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче