зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1253233: refactor bug331215_window.xul to run the test on remote browsers as well. r=felipe
This commit is contained in:
Родитель
13b9eb1ac7
Коммит
499fecf616
|
@ -5,6 +5,9 @@
|
|||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
|
||||
<window id="331215test"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
|
@ -14,53 +17,80 @@
|
|||
title="331215 test">
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Cr = Components.results;
|
||||
const {interfaces: Ci, classes: Cc, results: Cr, utils: Cu} = Components;
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://testing-common/ContentTask.jsm");
|
||||
ContentTask.setTestScope(window.opener.wrappedJSObject);
|
||||
|
||||
var gFindBar = null;
|
||||
var gBrowser;
|
||||
|
||||
var imports = ["SimpleTest", "ok"];
|
||||
var imports = ["SimpleTest", "ok", "info"];
|
||||
for (var name of imports) {
|
||||
window[name] = window.opener.wrappedJSObject[name];
|
||||
}
|
||||
|
||||
function finish() {
|
||||
window.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
gFindBar = document.getElementById("FindToolbar");
|
||||
gBrowser = document.getElementById("content");
|
||||
gBrowser.addEventListener("pageshow", onPageShow, false);
|
||||
gBrowser.loadURI("data:text/plain,latest");
|
||||
Task.spawn(function* () {
|
||||
gFindBar = document.getElementById("FindToolbar");
|
||||
for (let browserId of ["content", "content-remote"]) {
|
||||
yield startTestWithBrowser(browserId);
|
||||
}
|
||||
}).then(() => {
|
||||
window.close();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
function onPageShow() {
|
||||
function* startTestWithBrowser(browserId) {
|
||||
info("Starting test with browser '" + browserId + "'");
|
||||
gBrowser = document.getElementById(browserId);
|
||||
gFindBar.browser = gBrowser;
|
||||
let promise = ContentTask.spawn(gBrowser, null, function* () {
|
||||
return new Promise(resolve => {
|
||||
addEventListener("DOMContentLoaded", function listener() {
|
||||
removeEventListener("DOMContentLoaded", listener);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
gBrowser.loadURI("data:text/plain,latest");
|
||||
yield promise;
|
||||
yield onDocumentLoaded();
|
||||
}
|
||||
|
||||
function* onDocumentLoaded() {
|
||||
document.getElementById("cmd_find").doCommand();
|
||||
enterStringIntoFindField("test");
|
||||
yield enterStringIntoFindField("test");
|
||||
document.commandDispatcher
|
||||
.getControllerForCommand("cmd_moveTop")
|
||||
.doCommand("cmd_moveTop");
|
||||
enterStringIntoFindField("l");
|
||||
yield enterStringIntoFindField("l");
|
||||
ok(gFindBar._findField.getAttribute("status") == "notfound",
|
||||
"Findfield status attribute should have been 'notfound'" +
|
||||
" after entering ltest");
|
||||
enterStringIntoFindField("a");
|
||||
yield enterStringIntoFindField("a");
|
||||
ok(gFindBar._findField.getAttribute("status") != "notfound",
|
||||
"Findfield status attribute should not have been 'notfound'" +
|
||||
" after entering latest");
|
||||
finish();
|
||||
}
|
||||
|
||||
function enterStringIntoFindField(aString) {
|
||||
for (var i=0; i < aString.length; i++) {
|
||||
var event = document.createEvent("KeyEvents");
|
||||
function* enterStringIntoFindField(aString) {
|
||||
for (let i = 0; i < aString.length; i++) {
|
||||
let event = document.createEvent("KeyEvents");
|
||||
let promise = new Promise(resolve => {
|
||||
let listener = {
|
||||
onFindResult: function() {
|
||||
gFindBar.browser.finder.removeResultListener(listener);
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
gFindBar.browser.finder.addResultListener(listener);
|
||||
});
|
||||
event.initKeyEvent("keypress", true, true, null, false, false,
|
||||
false, false, 0, aString.charCodeAt(i));
|
||||
gFindBar._findField.inputField.dispatchEvent(event);
|
||||
yield promise;
|
||||
}
|
||||
}
|
||||
]]></script>
|
||||
|
@ -69,5 +99,6 @@
|
|||
<command id="cmd_find" oncommand="document.getElementById('FindToolbar').onFindCommand();"/>
|
||||
</commandset>
|
||||
<browser type="content-primary" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content-primary" flex="1" id="content-remote" remote="true" src="about:blank"/>
|
||||
<findbar id="FindToolbar" browserid="content"/>
|
||||
</window>
|
||||
|
|
Загрузка…
Ссылка в новой задаче