2013-06-11 18:23:00 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2017-03-18 14:26:05 +03:00
|
|
|
/* eslint-disable no-shadow */
|
|
|
|
|
|
|
|
"use strict";
|
2013-06-11 18:23:00 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test exceptions inside black boxed sources.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var gDebuggee;
|
|
|
|
var gClient;
|
|
|
|
var gThreadClient;
|
|
|
|
|
2017-03-18 14:26:05 +03:00
|
|
|
function run_test() {
|
2013-06-11 18:23:00 +04:00
|
|
|
initTestDebuggerServer();
|
|
|
|
gDebuggee = addTestGlobal("test-black-box");
|
|
|
|
gClient = new DebuggerClient(DebuggerServer.connectPipe());
|
2018-03-12 21:24:38 +03:00
|
|
|
gClient.connect().then(function() {
|
2017-03-18 14:26:05 +03:00
|
|
|
attachTestTabAndResume(
|
|
|
|
gClient, "test-black-box",
|
2018-03-12 21:24:38 +03:00
|
|
|
function(response, tabClient, threadClient) {
|
2017-03-18 14:26:05 +03:00
|
|
|
gThreadClient = threadClient;
|
|
|
|
// XXX: We have to do an executeSoon so that the error isn't caught and
|
|
|
|
// reported by DebuggerClient.requester (because we are using the local
|
|
|
|
// transport and share a stack) which causes the test to fail.
|
2017-04-14 19:29:12 +03:00
|
|
|
Services.tm.dispatchToMainThread({
|
2017-03-18 14:26:05 +03:00
|
|
|
run: test_black_box
|
2017-04-14 19:29:12 +03:00
|
|
|
});
|
2017-03-18 14:26:05 +03:00
|
|
|
});
|
2013-06-11 18:23:00 +04:00
|
|
|
});
|
|
|
|
do_test_pending();
|
|
|
|
}
|
|
|
|
|
|
|
|
const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
|
|
|
|
const SOURCE_URL = "http://example.com/source.js";
|
|
|
|
|
2017-03-18 14:26:05 +03:00
|
|
|
function test_black_box() {
|
2013-06-11 18:23:00 +04:00
|
|
|
gClient.addOneTimeListener("paused", test_black_box_exception);
|
|
|
|
|
2017-11-06 17:01:33 +03:00
|
|
|
/* eslint-disable no-multi-spaces, no-unreachable */
|
2018-02-28 20:51:33 +03:00
|
|
|
Cu.evalInSandbox(
|
2013-06-11 18:23:00 +04:00
|
|
|
"" + function doStuff(k) { // line 1
|
|
|
|
throw new Error("wu tang clan ain't nuthin' ta fuck wit"); // line 2
|
|
|
|
k(100); // line 3
|
|
|
|
}, // line 4
|
|
|
|
gDebuggee,
|
|
|
|
"1.8",
|
|
|
|
BLACK_BOXED_URL,
|
|
|
|
1
|
|
|
|
);
|
|
|
|
|
2018-02-28 20:51:33 +03:00
|
|
|
Cu.evalInSandbox(
|
2013-08-08 02:44:00 +04:00
|
|
|
"" + function runTest() { // line 1
|
|
|
|
doStuff( // line 2
|
2018-03-12 21:24:38 +03:00
|
|
|
function(n) { // line 3
|
2013-08-08 02:44:00 +04:00
|
|
|
debugger; // line 4
|
|
|
|
} // line 5
|
|
|
|
); // line 6
|
|
|
|
} // line 7
|
|
|
|
+ "\ndebugger;\n" // line 8
|
|
|
|
+ "try { runTest() } catch (ex) { }", // line 9
|
2013-06-11 18:23:00 +04:00
|
|
|
gDebuggee,
|
|
|
|
"1.8",
|
|
|
|
SOURCE_URL,
|
|
|
|
1
|
|
|
|
);
|
2017-11-06 17:01:33 +03:00
|
|
|
/* eslint-enable no-multi-spaces */
|
2013-06-11 18:23:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_black_box_exception() {
|
2018-03-12 21:24:38 +03:00
|
|
|
gThreadClient.getSources(function({error, sources}) {
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.ok(!error, "Should not get an error: " + error);
|
2017-03-18 14:26:05 +03:00
|
|
|
let sourceClient = gThreadClient.source(
|
|
|
|
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
|
|
|
|
);
|
2013-06-11 18:23:00 +04:00
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
sourceClient.blackBox(function({error}) {
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.ok(!error, "Should not get an error: " + error);
|
2013-06-11 18:23:00 +04:00
|
|
|
gThreadClient.pauseOnExceptions(true);
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
gClient.addOneTimeListener("paused", function(event, packet) {
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.equal(packet.frame.where.source.url, SOURCE_URL,
|
|
|
|
"We shouldn't pause while in the black boxed source.");
|
2013-06-11 18:23:00 +04:00
|
|
|
finishClient(gClient);
|
|
|
|
});
|
|
|
|
|
|
|
|
gThreadClient.resume();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|