diff options
Diffstat (limited to 'toolkit/devtools/app-manager/test/test_remain_connected.html')
-rw-r--r-- | toolkit/devtools/app-manager/test/test_remain_connected.html | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/toolkit/devtools/app-manager/test/test_remain_connected.html b/toolkit/devtools/app-manager/test/test_remain_connected.html new file mode 100644 index 000000000..819e3d6c0 --- /dev/null +++ b/toolkit/devtools/app-manager/test/test_remain_connected.html @@ -0,0 +1,122 @@ +<!DOCTYPE html> + +<!-- +Bug 912646 - Closing app toolbox causes phone to disconnect +--> + +<html> + + <head> + <meta charset="utf8"> + <title></title> + + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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"> + const Cu = Components.utils; + + Cu.import("resource://gre/modules/devtools/dbg-server.jsm"); + + if (!DebuggerServer.initialized) { + DebuggerServer.init(); + DebuggerServer.addBrowserActors(); + } + + window.onload = function() { + SimpleTest.waitForExplicitFinish(); + + Cu.import("resource:///modules/devtools/gDevTools.jsm"); + + const {devtools} = + Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); + const {require} = devtools; + + const {Connection, ConnectionManager} = + require("devtools/client/connection-manager"); + const ConnectionStore = + require("devtools/app-manager/connection-store"); + + let connection = ConnectionManager.createConnection(); + + connection.host = null; // force pipe + connection.port = null; + + let been_through_connecting = false; + let been_through_connected = false; + let been_through_disconnected = false; + + is(connection.status, Connection.Status.DISCONNECTED, + "status updated (diconnected)"); + + connection.once("connecting", () => { + SimpleTest.executeSoon(() => { + been_through_connecting = true; + is(connection.status, Connection.Status.CONNECTING, + "status updated (connecting)"); + }) + }); + + connection.once("connected", () => { + SimpleTest.executeSoon(() => { + been_through_connected = true; + is(connection.status, Connection.Status.CONNECTED, + "status updated (connected)"); + cycleToolbox(); + }) + }); + + function cycleToolbox() { + connection.client.listTabs(response => { + let options = { + form: response.tabs[0], + client: connection.client, + chrome: true + }; + devtools.TargetFactory.forRemoteTab(options).then(target => { + let hostType = devtools.Toolbox.HostType.WINDOW; + gDevTools.showToolbox(target, + null, + hostType).then(toolbox => { + SimpleTest.executeSoon(() => { + toolbox.once("destroyed", onDestroyToolbox); + toolbox.destroy(); + }); + }); + }); + }); + } + + function onDestroyToolbox() { + is(connection.status, Connection.Status.CONNECTED, + "toolbox cycled, still connected"); + connection.disconnect(); + } + + connection.once("disconnected", () => { + SimpleTest.executeSoon(() => { + been_through_disconnected = true; + is(connection.status, Connection.Status.DISCONNECTED, + "status updated (disconnected)"); + connection.destroy(); + finishUp(); + }) + }); + + function finishUp() { + ok(been_through_connecting && + been_through_connected && + been_through_disconnected, "All updates happened"); + DebuggerServer.destroy(); + SimpleTest.finish(); + } + + connection.connect(); + } + + </script> + </body> +</html> |