1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/app-manager/test/test_remain_connected.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,119 @@ 1.4 +<!DOCTYPE html> 1.5 + 1.6 +<!-- 1.7 +Bug 912646 - Closing app toolbox causes phone to disconnect 1.8 +--> 1.9 + 1.10 +<html> 1.11 + 1.12 + <head> 1.13 + <meta charset="utf8"> 1.14 + <title></title> 1.15 + 1.16 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.17 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 1.18 + </head> 1.19 + 1.20 + <body> 1.21 + 1.22 + <script type="application/javascript;version=1.8"> 1.23 + const Cu = Components.utils; 1.24 + 1.25 + Cu.import("resource://gre/modules/devtools/dbg-server.jsm"); 1.26 + DebuggerServer.init(function () { return true; }); 1.27 + DebuggerServer.addBrowserActors(); 1.28 + 1.29 + window.onload = function() { 1.30 + SimpleTest.waitForExplicitFinish(); 1.31 + 1.32 + Cu.import("resource:///modules/devtools/gDevTools.jsm"); 1.33 + 1.34 + const {devtools} = 1.35 + Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); 1.36 + const {require} = devtools; 1.37 + 1.38 + const {Connection, ConnectionManager} = 1.39 + require("devtools/client/connection-manager"); 1.40 + const ConnectionStore = 1.41 + require("devtools/app-manager/connection-store"); 1.42 + 1.43 + let connection = ConnectionManager.createConnection(); 1.44 + 1.45 + connection.host = null; // force pipe 1.46 + connection.port = null; 1.47 + 1.48 + let been_through_connecting = false; 1.49 + let been_through_connected = false; 1.50 + let been_through_disconnected = false; 1.51 + 1.52 + is(connection.status, Connection.Status.DISCONNECTED, 1.53 + "status updated (diconnected)"); 1.54 + 1.55 + connection.once("connecting", () => { 1.56 + SimpleTest.executeSoon(() => { 1.57 + been_through_connecting = true; 1.58 + is(connection.status, Connection.Status.CONNECTING, 1.59 + "status updated (connecting)"); 1.60 + }) 1.61 + }); 1.62 + 1.63 + connection.once("connected", () => { 1.64 + SimpleTest.executeSoon(() => { 1.65 + been_through_connected = true; 1.66 + is(connection.status, Connection.Status.CONNECTED, 1.67 + "status updated (connected)"); 1.68 + cycleToolbox(); 1.69 + }) 1.70 + }); 1.71 + 1.72 + function cycleToolbox() { 1.73 + connection.client.listTabs(response => { 1.74 + let options = { 1.75 + form: response.tabs[0], 1.76 + client: connection.client, 1.77 + chrome: true 1.78 + }; 1.79 + devtools.TargetFactory.forRemoteTab(options).then(target => { 1.80 + let hostType = devtools.Toolbox.HostType.WINDOW; 1.81 + gDevTools.showToolbox(target, 1.82 + null, 1.83 + hostType).then(toolbox => { 1.84 + SimpleTest.executeSoon(() => { 1.85 + toolbox.once("destroyed", onDestroyToolbox); 1.86 + toolbox.destroy(); 1.87 + }); 1.88 + }); 1.89 + }); 1.90 + }); 1.91 + } 1.92 + 1.93 + function onDestroyToolbox() { 1.94 + is(connection.status, Connection.Status.CONNECTED, 1.95 + "toolbox cycled, still connected"); 1.96 + connection.disconnect(); 1.97 + } 1.98 + 1.99 + connection.once("disconnected", () => { 1.100 + SimpleTest.executeSoon(() => { 1.101 + been_through_disconnected = true; 1.102 + is(connection.status, Connection.Status.DISCONNECTED, 1.103 + "status updated (disconnected)"); 1.104 + connection.destroy(); 1.105 + finishUp(); 1.106 + }) 1.107 + }); 1.108 + 1.109 + function finishUp() { 1.110 + ok(been_through_connecting && 1.111 + been_through_connected && 1.112 + been_through_disconnected, "All updates happened"); 1.113 + DebuggerServer.destroy(); 1.114 + SimpleTest.finish(); 1.115 + } 1.116 + 1.117 + connection.connect(); 1.118 + } 1.119 + 1.120 + </script> 1.121 + </body> 1.122 +</html>