Files
firefox/devtools/client/webide/test/test_runtime.html
T
Brian Grinstead 36c26fa2b9 Bug 1544322 - Part 1 - Remove the [type] attribute for one-liner <script> tags loading files in chrome://mochikit/content/ r=bzbarsky
This is an autogenerated commit to handle scripts loading mochitest harness files, in
the simple case where the script src is on the same line as the tag.

This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170
using the `--part 1` argument.

Differential Revision: https://phabricator.services.mozilla.com/D26812
2019-04-15 20:56:58 +00:00

208 lines
6.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title></title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/chrome-harness.js"></script>
<script type="application/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<script type="application/javascript">
window.onload = function() {
SimpleTest.waitForExplicitFinish();
let win;
SimpleTest.registerCleanupFunction(() => {
(async function() {
if (win) {
await closeWebIDE(win);
}
DebuggerServer.destroy();
await removeAllProjects();
})();
});
(async function() {
function isPlayActive() {
return !win.document.querySelector("#cmd_play").hasAttribute("disabled");
}
function isStopActive() {
return !win.document.querySelector("#cmd_stop").hasAttribute("disabled");
}
DebuggerServer.init();
DebuggerServer.registerAllActors();
win = await openWebIDE();
const docRuntime = getRuntimeDocument(win);
const docProject = getProjectDocument(win);
const winProject = getProjectWindow(win);
const packagedAppLocation = getTestFilePath("app");
const onValidated = waitForUpdate(win, "project-validated");
const onDetails = waitForUpdate(win, "details");
await winProject.projectList.importPackagedApp(packagedAppLocation);
await onValidated;
await onDetails;
win.AppManager.runtimeList.usb.push({
connect: function(connection) {
is(connection, win.AppManager.connection, "connection is valid");
connection.host = null; // force connectPipe
connection.connect();
return Promise.resolve();
},
get name() {
return "fakeRuntime";
},
});
win.AppManager.runtimeList.usb.push({
connect: function(connection) {
return new Promise(() => {});
},
get name() {
return "infiniteRuntime";
},
});
win.AppManager.runtimeList.usb.push({
connect: function(connection) {
return new Promise(() => {});
},
prolongedConnection: true,
get name() {
return "prolongedRuntime";
},
});
win.AppManager.update("runtime-list");
const panelNode = docRuntime.querySelector("#runtime-panel");
const items = panelNode.querySelectorAll(".runtime-panel-item-usb");
is(items.length, 3, "Found 3 runtime buttons");
let onGlobalActors = waitForUpdate(win, "runtime-global-actors");
let connectionsChanged = waitForConnectionChange("opened");
items[0].click();
ok(win.document.querySelector("window").classList.contains("busy"),
"UI is busy");
await win.UI._busyPromise;
await connectionsChanged;
is(Object.keys(DebuggerServer._connections).length, 1, "Connected");
await onGlobalActors;
// Play button always disabled now, webapps actor removed
ok(!isPlayActive(), "play button is disabled");
ok(!isStopActive(), "stop button is disabled");
const oldProject = win.AppManager.selectedProject;
win.AppManager.selectedProject = null;
await nextTick();
ok(!isPlayActive(), "play button is disabled");
ok(!isStopActive(), "stop button is disabled");
win.AppManager._selectedProject = oldProject;
win.UI.updateCommands();
await nextTick();
ok(!isPlayActive(), "play button is enabled");
ok(!isStopActive(), "stop button is disabled");
connectionsChanged = waitForConnectionChange("closed");
await win.Cmds.disconnectRuntime();
await connectionsChanged;
is(Object.keys(DebuggerServer._connections).length, 0, "Disconnected");
ok(win.AppManager.selectedProject, "A project is still selected");
ok(!isPlayActive(), "play button is disabled");
ok(!isStopActive(), "stop button is disabled");
connectionsChanged = waitForConnectionChange("opened");
onGlobalActors = waitForUpdate(win, "runtime-global-actors");
const onRuntimeTargets = waitForUpdate(win, "runtime-targets");
docRuntime.querySelectorAll(".runtime-panel-item-other")[1].click();
await connectionsChanged;
await onGlobalActors;
await onRuntimeTargets;
is(Object.keys(DebuggerServer._connections).length, 1, "Locally connected");
ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
// Select main process
SimpleTest.executeSoon(() => {
docProject.querySelectorAll("#project-panel-runtimeapps .panel-item")[0].click();
});
await waitForUpdate(win, "project");
// Toolbox opens automatically for main process / runtime apps
ok(win.UI.toolboxPromise, "Toolbox promise exists");
await win.UI.toolboxPromise;
await win.Cmds.disconnectRuntime();
Services.prefs.setIntPref("devtools.webide.busyTimeout", 100);
// Click the infinite runtime
items[1].click();
ok(win.document.querySelector("window").classList.contains("busy"),
"UI is busy");
// Wait for error message since connection never completes
await new Promise(resolve => {
win.UI.reportError = errorName => {
if (errorName === "error_operationTimeout") {
resolve();
}
};
});
// Click the prolonged runtime
items[2].click();
ok(win.document.querySelector("window").classList.contains("busy"),
"UI is busy");
// Check for unexpected error message since this is prolonged
const noErrorDeferred = new Promise((resolve, reject) => {
win.UI.reportError = errorName => {
if (errorName === "error_operationTimeout") {
reject();
}
};
setTimeout(() => {
resolve();
}, 1000);
});
await noErrorDeferred;
SimpleTest.finish();
})();
};
</script>
</body>
</html>