diff --git a/browser/devtools/debugger/test/browser_dbg_break-on-dom-08.js b/browser/devtools/debugger/test/browser_dbg_break-on-dom-08.js index 10ed59bc3176..e8ffb993493d 100644 --- a/browser/devtools/debugger/test/browser_dbg_break-on-dom-08.js +++ b/browser/devtools/debugger/test/browser_dbg_break-on-dom-08.js @@ -34,7 +34,7 @@ function test() { yield ensureThreadClientState(aPanel, "resumed"); let paused = waitForCaretAndScopes(aPanel, 48); - sendMouseClickToTab(gTab, content.document.body); + generateMouseClickInTab(gTab, "content.document.body"); yield paused; yield ensureThreadClientState(aPanel, "paused"); diff --git a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js index 9cf0d01d1c55..54ee5e2c1d6b 100644 --- a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js @@ -96,7 +96,7 @@ function test() { ok(isCaretPos(gPanel, 9), "The editor location is correct before pausing."); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return finished; } diff --git a/browser/devtools/debugger/test/browser_dbg_breakpoints-new-script.js b/browser/devtools/debugger/test/browser_dbg_breakpoints-new-script.js index b92472c653e7..ac5a3945ad9c 100644 --- a/browser/devtools/debugger/test/browser_dbg_breakpoints-new-script.js +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-new-script.js @@ -54,7 +54,7 @@ function testResume() { }); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_closure-inspection.js b/browser/devtools/debugger/test/browser_dbg_closure-inspection.js index 47c99e57d586..681ee9e198b8 100644 --- a/browser/devtools/debugger/test/browser_dbg_closure-inspection.js +++ b/browser/devtools/debugger/test/browser_dbg_closure-inspection.js @@ -22,7 +22,7 @@ function test() { }); function testClosure() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { let gVars = gDebugger.DebuggerView.Variables; diff --git a/browser/devtools/debugger/test/browser_dbg_event-listeners-01.js b/browser/devtools/debugger/test/browser_dbg_event-listeners-01.js index 675bd64cfbb3..69ad18b60e8a 100644 --- a/browser/devtools/debugger/test/browser_dbg_event-listeners-01.js +++ b/browser/devtools/debugger/test/browser_dbg_event-listeners-01.js @@ -49,7 +49,7 @@ function pauseDebuggee(aThreadClient) { deferred.resolve(aThreadClient); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return deferred.promise; } diff --git a/browser/devtools/debugger/test/browser_dbg_event-listeners-02.js b/browser/devtools/debugger/test/browser_dbg_event-listeners-02.js index 8f5c5e5bbcf4..606e4bb81917 100644 --- a/browser/devtools/debugger/test/browser_dbg_event-listeners-02.js +++ b/browser/devtools/debugger/test/browser_dbg_event-listeners-02.js @@ -50,7 +50,7 @@ function pauseDebuggee(aThreadClient) { deferred.resolve(aThreadClient); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return deferred.promise; } diff --git a/browser/devtools/debugger/test/browser_dbg_event-listeners-03.js b/browser/devtools/debugger/test/browser_dbg_event-listeners-03.js index 0173919df007..69c69627094a 100644 --- a/browser/devtools/debugger/test/browser_dbg_event-listeners-03.js +++ b/browser/devtools/debugger/test/browser_dbg_event-listeners-03.js @@ -50,7 +50,7 @@ function pauseDebuggee(aThreadClient) { deferred.resolve(aThreadClient); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return deferred.promise; } diff --git a/browser/devtools/debugger/test/browser_dbg_hit-counts-01.js b/browser/devtools/debugger/test/browser_dbg_hit-counts-01.js index 841362b7a64d..9ea03c310ef8 100644 --- a/browser/devtools/debugger/test/browser_dbg_hit-counts-01.js +++ b/browser/devtools/debugger/test/browser_dbg_hit-counts-01.js @@ -43,7 +43,7 @@ function test() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } function testHitCounts() { diff --git a/browser/devtools/debugger/test/browser_dbg_hit-counts-02.js b/browser/devtools/debugger/test/browser_dbg_hit-counts-02.js index fb9788e9d99a..6cff1e45c80d 100644 --- a/browser/devtools/debugger/test/browser_dbg_hit-counts-02.js +++ b/browser/devtools/debugger/test/browser_dbg_hit-counts-02.js @@ -45,7 +45,7 @@ function test() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } function testHitCountsBeforeStopping() { diff --git a/browser/devtools/debugger/test/browser_dbg_optimized-out-vars.js b/browser/devtools/debugger/test/browser_dbg_optimized-out-vars.js index a88f7d04a821..394c4e0e5575 100644 --- a/browser/devtools/debugger/test/browser_dbg_optimized-out-vars.js +++ b/browser/devtools/debugger/test/browser_dbg_optimized-out-vars.js @@ -19,7 +19,7 @@ function test() { // Spin the event loop before causing the debuggee to pause, to allow // this function to return first. - sendMouseClickToTab(tab, content.document.querySelector("button")); + generateMouseClickInTab(tab, "content.document.querySelector('button')"); yield waitForDebuggerEvents(panel, gDebugger.EVENTS.FETCHED_SCOPES); let gVars = gDebugger.DebuggerView.Variables; diff --git a/browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js b/browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js index e894050e3507..9d232f509ddf 100644 --- a/browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js +++ b/browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js @@ -77,7 +77,7 @@ function testPauseOnExceptionsDisabled() { return finished; }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return finished; } @@ -148,7 +148,7 @@ function testPauseOnExceptionsEnabled() { return finished; }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return finished; } diff --git a/browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js b/browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js index aa7c03adac9b..0e417ae8bebc 100644 --- a/browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js +++ b/browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js @@ -104,7 +104,7 @@ function testPauseOnExceptionsAfterReload() { return finished; }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); return finished; } diff --git a/browser/devtools/debugger/test/browser_dbg_step-out.js b/browser/devtools/debugger/test/browser_dbg_step-out.js index 9d799d0ee96a..e7f10800c624 100644 --- a/browser/devtools/debugger/test/browser_dbg_step-out.js +++ b/browser/devtools/debugger/test/browser_dbg_step-out.js @@ -40,7 +40,7 @@ function testNormalReturn() { gDebugger); }); - sendMouseClickToTab(gTab, content.document.getElementById("return")); + generateMouseClickInTab(gTab, "content.document.getElementById('return')"); } function testReturnWithException() { @@ -62,7 +62,7 @@ function testReturnWithException() { gDebugger); }); - sendMouseClickToTab(gTab, content.document.getElementById("throw")); + generateMouseClickInTab(gTab, "content.document.getElementById('throw')"); } function resumeDebuggee() { diff --git a/browser/devtools/debugger/test/browser_dbg_tracing-01.js b/browser/devtools/debugger/test/browser_dbg_tracing-01.js index acc56e994ac1..272173c4d49e 100644 --- a/browser/devtools/debugger/test/browser_dbg_tracing-01.js +++ b/browser/devtools/debugger/test/browser_dbg_tracing-01.js @@ -36,7 +36,7 @@ function test() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } function testTraceLogs() { diff --git a/browser/devtools/debugger/test/browser_dbg_tracing-02.js b/browser/devtools/debugger/test/browser_dbg_tracing-02.js index eb55db1610cf..476aadbde811 100644 --- a/browser/devtools/debugger/test/browser_dbg_tracing-02.js +++ b/browser/devtools/debugger/test/browser_dbg_tracing-02.js @@ -39,7 +39,7 @@ function test() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } function highlightCall() { diff --git a/browser/devtools/debugger/test/browser_dbg_tracing-03.js b/browser/devtools/debugger/test/browser_dbg_tracing-03.js index e8bcbe8f913c..79c510686959 100644 --- a/browser/devtools/debugger/test/browser_dbg_tracing-03.js +++ b/browser/devtools/debugger/test/browser_dbg_tracing-03.js @@ -50,7 +50,7 @@ function test() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } function clickTraceLog() { diff --git a/browser/devtools/debugger/test/browser_dbg_tracing-04.js b/browser/devtools/debugger/test/browser_dbg_tracing-04.js index c5976c6cb2c9..9ec1c82210e8 100644 --- a/browser/devtools/debugger/test/browser_dbg_tracing-04.js +++ b/browser/devtools/debugger/test/browser_dbg_tracing-04.js @@ -40,7 +40,7 @@ function test() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } function clickTraceCall() { diff --git a/browser/devtools/debugger/test/browser_dbg_tracing-05.js b/browser/devtools/debugger/test/browser_dbg_tracing-05.js index a51cc0ae111f..c811618cb6a0 100644 --- a/browser/devtools/debugger/test/browser_dbg_tracing-05.js +++ b/browser/devtools/debugger/test/browser_dbg_tracing-05.js @@ -69,7 +69,7 @@ function testNoEmptyText() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } registerCleanupFunction(function() { diff --git a/browser/devtools/debugger/test/browser_dbg_tracing-07.js b/browser/devtools/debugger/test/browser_dbg_tracing-07.js index 4aaba2c41b52..dc1ccaec9150 100644 --- a/browser/devtools/debugger/test/browser_dbg_tracing-07.js +++ b/browser/devtools/debugger/test/browser_dbg_tracing-07.js @@ -60,7 +60,7 @@ function test() { } function clickButton() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); } function pushPref() { diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-01.js b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-01.js index d15fd6b2a71a..b3389fcd1838 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-01.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-01.js @@ -114,7 +114,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-02.js b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-02.js index 7c760b1af0bb..3aa7fa05cbc8 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-02.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-02.js @@ -35,7 +35,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-edit-value.js b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-value.js index c58e6c0da5d0..836949088cc4 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-edit-value.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-value.js @@ -37,7 +37,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js index 4555a0dadf68..9c6f28bd7c26 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js @@ -36,7 +36,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-02.js b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-02.js index 9590366f41b9..ccb74fbd3f6b 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-02.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-02.js @@ -36,7 +36,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-03.js b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-03.js index 6ed1f21358a4..0af74650d1b6 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-03.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-03.js @@ -35,7 +35,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-04.js b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-04.js index 26b99a93ba20..9681d11eb20d 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-04.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-04.js @@ -36,7 +36,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-05.js b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-05.js index 0e5f0b040737..ad28b77a0d83 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-05.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-05.js @@ -35,7 +35,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-01.js b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-01.js index 2e0baeadde2e..a81fc932482c 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-01.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-01.js @@ -29,7 +29,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-02.js b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-02.js index c48ace4ef509..88e166de446c 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-02.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-02.js @@ -34,7 +34,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-03.js b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-03.js index d667ce67324e..d42f69cdfbd1 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-03.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-03.js @@ -31,7 +31,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-with.js b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-with.js index c9d8d9d60acc..363a89d4cab4 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-frame-with.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-with.js @@ -33,7 +33,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-large-array-buffer.js b/browser/devtools/debugger/test/browser_dbg_variables-view-large-array-buffer.js index 7dd27c712411..a227c9badffc 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-large-array-buffer.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-large-array-buffer.js @@ -28,7 +28,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-01.js b/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-01.js index ce9c74eef0e6..4f848e19d65a 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-01.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-01.js @@ -44,7 +44,7 @@ function addBreakpoint() { } function pauseDebuggee() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); // The first 'with' scope should be expanded by default, but the // variables haven't been fetched yet. This is how 'with' scopes work. diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-02.js b/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-02.js index 1afa7370fb35..c51388da1793 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-02.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-reexpand-02.js @@ -45,7 +45,7 @@ function addBreakpoint() { } function pauseDebuggee() { - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); // The first 'with' scope should be expanded by default, but the // variables haven't been fetched yet. This is how 'with' scopes work. diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-webidl.js b/browser/devtools/debugger/test/browser_dbg_variables-view-webidl.js index a0f598d69645..ba65feb0c4c7 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-webidl.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-webidl.js @@ -29,7 +29,7 @@ function test() { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); - sendMouseClickToTab(gTab, content.document.querySelector("button")); + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); }); } diff --git a/browser/devtools/debugger/test/code_frame-script.js b/browser/devtools/debugger/test/code_frame-script.js index 0fdb4ac674fe..529328cbd0f2 100644 --- a/browser/devtools/debugger/test/code_frame-script.js +++ b/browser/devtools/debugger/test/code_frame-script.js @@ -9,59 +9,77 @@ loadSubScript("chrome://marionette/content/EventUtils.js", EventUtils); dump("Frame script loaded.\n"); -addMessageListener("test:call", function (message) { - dump("Calling function with name " + message.data.name + ".\n"); - - let data = message.data; - let result = XPCNativeWrapper.unwrap(content)[data.name].apply(undefined, data.args); - if (result && result.then) { - result.then(() => { - sendAsyncMessage("test:call"); - }); - } else { - sendAsyncMessage("test:call"); - } -}); - -addMessageListener("test:click", function (message) { - dump("Sending mouse click.\n"); - - let target = message.objects.target; - EventUtils.synthesizeMouseAtCenter(target, {}, - target.ownerDocument.defaultView); -}); - -addMessageListener("test:eval", function (message) { - dump("Evalling string " + message.data.string + ".\n"); - - let result = content.eval(message.data.string); - if (result.then) { - result.then(() => { - sendAsyncMessage("test:eval"); - }); - } else { - sendAsyncMessage("test:eval"); - } -}); - let workers = {} -addMessageListener("test:createWorker", function (message) { - dump("Creating worker with url '" + message.data.url + "'.\n"); +this.call = function (name, args) { + dump("Calling function with name " + name + ".\n"); - let url = message.data.url; - let worker = new content.Worker(message.data.url); - worker.addEventListener("message", function listener() { - worker.removeEventListener("message", listener); - sendAsyncMessage("test:createWorker"); + dump("args " + JSON.stringify(args) + "\n"); + return XPCNativeWrapper.unwrap(content)[name].apply(undefined, args); +}; + +this._eval = function (string) { + dump("Evalling string.\n"); + + return content.eval(string); +}; + +this.generateMouseClick = function (path) { + dump("Generating mouse click.\n"); + + let target = eval(path); + EventUtils.synthesizeMouseAtCenter(target, {}, + target.ownerDocument.defaultView); +}; + +this.createWorker = function (url) { + dump("Creating worker with url '" + url + "'.\n"); + + return new Promise(function (resolve, reject) { + let worker = new content.Worker(url); + worker.addEventListener("message", function listener() { + worker.removeEventListener("message", listener); + workers[url] = worker; + resolve(); + }); }); - workers[url] = worker; -}); +}; -addMessageListener("test:terminateWorker", function (message) { - dump("Terminating worker with url '" + message.data.url + "'.\n"); +this.terminateWorker = function (url) { + dump("Terminating worker with url '" + url + "'.\n"); - let url = message.data.url; workers[url].terminate(); delete workers[url]; +}; + +this.postMessageToWorker = function (url, message) { + dump("Posting message to worker with url '" + url + "'.\n"); + + return new Promise(function (resolve) { + let worker = workers[url]; + worker.postMessage(message); + worker.addEventListener("message", function listener() { + worker.removeEventListener("message", listener); + resolve(); + }); + }); +}; + +addMessageListener("jsonrpc", function ({ data: { method, params, id } }) { + method = this[method]; + Promise.resolve().then(function () { + return method.apply(undefined, params); + }).then(function (result) { + sendAsyncMessage("jsonrpc", { + result: result, + error: null, + id: id + }); + }, function (error) { + sendAsyncMessage("jsonrpc", { + result: null, + error: error.message.toString(), + id: id + }); + }); }); diff --git a/browser/devtools/debugger/test/head.js b/browser/devtools/debugger/test/head.js index ecee083d2193..1002c36717c6 100644 --- a/browser/devtools/debugger/test/head.js +++ b/browser/devtools/debugger/test/head.js @@ -959,51 +959,6 @@ function popPrefs() { return deferred.promise; } -function sendMessageToTab(tab, name, data, objects) { - info("Sending message with name " + name + " to tab."); - - tab.linkedBrowser.messageManager.sendAsyncMessage(name, data, objects); -} - -function waitForMessageFromTab(tab, name) { - info("Waiting for message with name " + name + " from tab."); - - return new Promise(function (resolve) { - let messageManager = tab.linkedBrowser.messageManager; - messageManager.addMessageListener(name, function listener(message) { - messageManager.removeMessageListener(name, listener); - resolve(message); - }); - }); -} - -function callInTab(tab, name) { - info("Calling function with name " + name + " in tab."); - - sendMessageToTab(tab, "test:call", { - name: name, - args: Array.prototype.slice.call(arguments, 2) - }); - return waitForMessageFromTab(tab, "test:call"); -} - -function evalInTab(tab, string) { - info("Evalling string " + string + " in tab."); - - sendMessageToTab(tab, "test:eval", { - string: string, - }); - return waitForMessageFromTab(tab, "test:eval"); -} - -function sendMouseClickToTab(tab, target) { - info("Sending mouse click to tab."); - - sendMessageToTab(tab, "test:click", undefined, { - target: target - }); -} - // Source helpers function getSelectedSourceURL(aSources) { @@ -1026,22 +981,68 @@ function getSourceForm(aSources, aURL) { return item.attachment.source; } +let nextId = 0; + +function jsonrpc(tab, method, params) { + return new Promise(function (resolve, reject) { + let currentId = nextId++; + let messageManager = tab.linkedBrowser.messageManager; + messageManager.sendAsyncMessage("jsonrpc", { + method: method, + params: params, + id: currentId + }); + messageManager.addMessageListener("jsonrpc", function listener({ + data: { result, error, id } + }) { + if (id !== currentId) { + return; + } + + messageManager.removeMessageListener("jsonrpc", listener); + if (error != null) { + reject(error); + } + + resolve(result); + }); + }); +} + +function callInTab(tab, name) { + info("Calling function with name '" + name + "' in tab."); + + return jsonrpc(tab, "call", [name, Array.prototype.slice.call(arguments, 2)]); +} + +function evalInTab(tab, string) { + info("Evalling string in tab."); + + return jsonrpc(tab, "_eval", [string]); +} + function createWorkerInTab(tab, url) { info("Creating worker with url '" + url + "' in tab."); - sendMessageToTab(tab, "test:createWorker", { - url: url - }); - return waitForMessageFromTab(tab, "test:createWorker"); + return jsonrpc(tab, "createWorker", [url]); } function terminateWorkerInTab(tab, url) { info("Terminating worker with url '" + url + "' in tab."); - sendMessageToTab(tab, "test:terminateWorker", { - url: url - }); - return waitForMessageFromTab(tab, "test:terminateWorker"); + return jsonrpc(tab, "terminateWorker", [url]); +} + +function postMessageToWorkerInTab(tab, url, message) { + info("Posting message to worker with url '" + url + "' in tab."); + + return jsonrpc(tab, "postMessageToWorker", [url, message]); +} + +function generateMouseClickInTab(tab, path) { + info("Generating mouse click in tab."); + + return jsonrpc(tab, "generateMouseClick", [path]); } function connect(client) {