зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to b2g-inbound a=merge
This commit is contained in:
Коммит
fd6aa61643
|
@ -11,12 +11,11 @@ import org.mozilla.gecko.Element;
|
|||
import org.mozilla.gecko.R;
|
||||
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
import org.mozilla.gecko.util.NativeEventListener;
|
||||
import org.mozilla.gecko.util.NativeJSObject;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class testFindInPage extends JavascriptTest implements NativeEventListener {
|
||||
public class testFindInPage extends JavascriptTest implements GeckoEventListener {
|
||||
private static final int WAIT_FOR_TEST = 3000;
|
||||
protected Element next, close;
|
||||
|
||||
|
@ -25,15 +24,14 @@ public class testFindInPage extends JavascriptTest implements NativeEventListene
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(final String event, final NativeJSObject message,
|
||||
final EventCallback callback) {
|
||||
public void handleMessage(String event, final JSONObject message) {
|
||||
if (event.equals("Test:FindInPage")) {
|
||||
try {
|
||||
final String text = message.getString("text");
|
||||
final int nrOfMatches = message.getInt("nrOfMatches");
|
||||
final int nrOfMatches = Integer.parseInt(message.getString("nrOfMatches"));
|
||||
findText(text, nrOfMatches);
|
||||
} catch (Exception e) {
|
||||
callback.sendError("Can't extract find query from JSON :" + e.toString());
|
||||
fFail("Can't extract find query from JSON");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,11 +39,9 @@ public class testFindInPage extends JavascriptTest implements NativeEventListene
|
|||
try {
|
||||
close.click();
|
||||
} catch (Exception e) {
|
||||
callback.sendError("FindInPage prompt not opened");
|
||||
fFail("FindInPage prompt not opened");
|
||||
}
|
||||
}
|
||||
|
||||
callback.sendSuccess("done");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,21 +35,17 @@ function openTabWithUrl(url) {
|
|||
}
|
||||
|
||||
function findInPage(browser, text, nrOfMatches) {
|
||||
do_print("Send findInPageMessage: " + text + " nth: " + nrOfMatches);
|
||||
let messagePromise = Messaging.sendRequestForResult({
|
||||
type: "Test:FindInPage",
|
||||
text: text,
|
||||
nrOfMatches: nrOfMatches
|
||||
});
|
||||
let repaintPromise = promiseBrowserEvent(browser, "MozAfterPaint");
|
||||
return Promise.all([messagePromise, repaintPromise]);
|
||||
do_print("Send findInPageMessage: " + text + " nth: " + nrOfMatches);
|
||||
Messaging.sendRequest({ type: "Test:FindInPage", text: text, nrOfMatches: nrOfMatches });
|
||||
return repaintPromise;
|
||||
}
|
||||
|
||||
function closeFindInPage(browser) {
|
||||
do_print("Send closeFindInPageMessage");
|
||||
let messagePromise = Messaging.sendRequestForResult({ type: "Test:CloseFindInPage" });
|
||||
let repaintPromise = promiseBrowserEvent(browser, "MozAfterPaint");
|
||||
return Promise.all([messagePromise, repaintPromise]);
|
||||
do_print("Send closeFindInPageMessage");
|
||||
Messaging.sendRequest({ type: "Test:CloseFindInPage" });
|
||||
return repaintPromise;
|
||||
}
|
||||
|
||||
function assertSelection(document, expectedSelection = false, expectedAnchorText = false) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче