Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>"; |
michael@0 | 5 | |
michael@0 | 6 | let temp = {}; |
michael@0 | 7 | |
michael@0 | 8 | Cu.import("resource://gre/modules/devtools/dbg-server.jsm", temp); |
michael@0 | 9 | let DebuggerServer = temp.DebuggerServer; |
michael@0 | 10 | |
michael@0 | 11 | Cu.import("resource://gre/modules/devtools/dbg-client.jsm", temp); |
michael@0 | 12 | let DebuggerClient = temp.DebuggerClient; |
michael@0 | 13 | let debuggerSocketConnect = temp.debuggerSocketConnect; |
michael@0 | 14 | |
michael@0 | 15 | Cu.import("resource:///modules/devtools/profiler/controller.js", temp); |
michael@0 | 16 | let ProfilerController = temp.ProfilerController; |
michael@0 | 17 | |
michael@0 | 18 | function test() { |
michael@0 | 19 | waitForExplicitFinish(); |
michael@0 | 20 | Services.prefs.setBoolPref(REMOTE_ENABLED, true); |
michael@0 | 21 | |
michael@0 | 22 | loadTab(URL, function onTabLoad(tab, browser) { |
michael@0 | 23 | DebuggerServer.init(function () true); |
michael@0 | 24 | DebuggerServer.addBrowserActors(); |
michael@0 | 25 | is(DebuggerServer._socketConnections, 0); |
michael@0 | 26 | |
michael@0 | 27 | DebuggerServer.openListener(2929); |
michael@0 | 28 | is(DebuggerServer._socketConnections, 1); |
michael@0 | 29 | |
michael@0 | 30 | let transport = debuggerSocketConnect("127.0.0.1", 2929); |
michael@0 | 31 | let client = new DebuggerClient(transport); |
michael@0 | 32 | client.connect(function onClientConnect() { |
michael@0 | 33 | let target = { isRemote: true, client: client }; |
michael@0 | 34 | let controller = new ProfilerController(target); |
michael@0 | 35 | |
michael@0 | 36 | controller.connect(function onControllerConnect() { |
michael@0 | 37 | // If this callback is called, this means listTabs call worked. |
michael@0 | 38 | // Which means that the transport worked. Time to finish up this |
michael@0 | 39 | // test. |
michael@0 | 40 | |
michael@0 | 41 | function onShutdown() { |
michael@0 | 42 | window.removeEventListener("Debugger:Shutdown", onShutdown, true); |
michael@0 | 43 | transport = client = null; |
michael@0 | 44 | finish(); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | window.addEventListener("Debugger:Shutdown", onShutdown, true); |
michael@0 | 48 | |
michael@0 | 49 | client.close(function () { |
michael@0 | 50 | gBrowser.removeTab(tab); |
michael@0 | 51 | }); |
michael@0 | 52 | }); |
michael@0 | 53 | }); |
michael@0 | 54 | }); |
michael@0 | 55 | } |