summaryrefslogtreecommitdiff
path: root/toolkit/devtools/webide/test/test_runtime.html
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/devtools/webide/test/test_runtime.html')
-rw-r--r--toolkit/devtools/webide/test/test_runtime.html147
1 files changed, 147 insertions, 0 deletions
diff --git a/toolkit/devtools/webide/test/test_runtime.html b/toolkit/devtools/webide/test/test_runtime.html
new file mode 100644
index 000000000..895bab4af
--- /dev/null
+++ b/toolkit/devtools/webide/test/test_runtime.html
@@ -0,0 +1,147 @@
+<!DOCTYPE html>
+
+<html>
+
+ <head>
+ <meta charset="utf8">
+ <title></title>
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
+ <script type="application/javascript;version=1.8" src="head.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+ </head>
+
+ <body>
+
+ <script type="application/javascript;version=1.8">
+ window.onload = function() {
+ SimpleTest.waitForExplicitFinish();
+
+ let win;
+
+ SimpleTest.registerCleanupFunction(() => {
+ Task.spawn(function*() {
+ if (win) {
+ yield closeWebIDE(win);
+ }
+ DebuggerServer.destroy();
+ yield removeAllProjects();
+ });
+ });
+
+ Task.spawn(function* () {
+
+ function isPlayActive() {
+ return !win.document.querySelector("#cmd_play").hasAttribute("disabled");
+ }
+
+ function isStopActive() {
+ return !win.document.querySelector("#cmd_stop").hasAttribute("disabled");
+ }
+
+ Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+
+ if (!DebuggerServer.initialized) {
+ DebuggerServer.init();
+ DebuggerServer.addBrowserActors();
+ }
+
+ win = yield openWebIDE();
+
+ 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.update("runtimelist");
+
+ let packagedAppLocation = getTestFilePath("app");
+
+ yield win.Cmds.importPackagedApp(packagedAppLocation);
+
+ let panelNode = win.document.querySelector("#runtime-panel");
+ let items = panelNode.querySelectorAll(".runtime-panel-item-usb");
+ is(items.length, 1, "Found one runtime button");
+
+ let deferred = promise.defer();
+ win.AppManager.connection.once(
+ win.Connection.Events.CONNECTED,
+ () => deferred.resolve());
+
+ items[0].click();
+
+ ok(win.document.querySelector("window").className, "busy", "UI is busy");
+ yield win.UI._busyPromise;
+
+ is(Object.keys(DebuggerServer._connections).length, 1, "Connected");
+
+ yield waitForUpdate(win, "runtime-apps-found");
+
+ ok(isPlayActive(), "play button is enabled 1");
+ ok(!isStopActive(), "stop button is disabled 1");
+ let oldProject = win.AppManager.selectedProject;
+ win.AppManager.selectedProject = null;
+
+ yield nextTick();
+
+ ok(!isPlayActive(), "play button is disabled 2");
+ ok(!isStopActive(), "stop button is disabled 2");
+ win.AppManager._selectedProject = oldProject;
+ win.UI.updateCommands();
+
+ yield nextTick();
+
+ ok(isPlayActive(), "play button is enabled 3");
+ ok(!isStopActive(), "stop button is disabled 3");
+
+
+ yield win.Cmds.disconnectRuntime();
+
+ is(Object.keys(DebuggerServer._connections).length, 0, "Disconnected");
+
+ ok(win.AppManager.selectedProject, "A project is still selected");
+ ok(!isPlayActive(), "play button is disabled 4");
+ ok(!isStopActive(), "stop button is disabled 4");
+
+ win.document.querySelectorAll(".runtime-panel-item-other")[1].click();
+
+ yield waitForUpdate(win, "runtime-apps-found");
+
+ is(Object.keys(DebuggerServer._connections).length, 1, "Locally connected");
+
+ ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
+
+ // Select main process
+ yield win.Cmds.showProjectPanel();
+ SimpleTest.executeSoon(() => {
+ win.document.querySelectorAll("#project-panel-runtimeapps .panel-item")[0].click();
+ });
+
+ yield waitForUpdate(win, "project");
+
+ // Toolbox opens automatically for main process / runtime apps
+ ok(win.UI.toolboxPromise, "Toolbox promise exists");
+ yield win.UI.toolboxPromise;
+
+ ok(win.UI.toolboxIframe, "Toolbox iframe exists");
+
+ yield win.Cmds.disconnectRuntime();
+
+ SimpleTest.finish();
+
+ });
+ }
+
+
+ </script>
+ </body>
+</html>