gecko/toolkit/devtools/server/tests/unit/test_sourcemaps-04.js
Bobby Holley 26926302d8 Bug 889911 - Switch xpcshell to SystemErrorReporter with a little bit of special magic. r=mrbkap
XPCShell currently overrides all the JSContexts whose creation it observes with
its own custom error reporter. This reporter does all sorts of funny things which
we try to clean up for the most part. But there are a few very intricate
considerations at play.

First, the old xpcshell error reporter does some mumbo jumbo with the
XPCCallContext stack to try to guess whether some other code might catch the
exception. This is total garbage on a number of fronts, particularly because
the XPCCallContext stack has no concept of saved frame chains, nested event
loops, sandbox boundaries, origin boundaries, or any of the myriad of
complicating factors that determine whether or not an exception will propagate.

So we get rid of it. But this causes some crazy debugger tests to fail, because
they rely on an exception from uriloader/exthandler/nsHandlerService.js getting
squelched, and can't handle anybody reporting errors to the console service at
the particular moment of contortionism when the exception is raised. So we need
to introduce an explicit mechanism to disable the error reporter here to keep
things running.

Second, we have to be very careful about tracking the return status of the
xpcshell binary. The old code would simply flag an error code if the error
handler was invoked, and we can mostly continue to do that. But there are some
complications. See the comments.

Finally, we don't anything analogous in XPCShellEnvironment, because I have
patches in bug 889714 to remove its state-dependence on the error reporter.
I'll switch it to SystemErrorReporter in that bug.
2013-07-16 20:38:44 -07:00

58 lines
2.0 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Check that absolute source map urls work.
*/
var gDebuggee;
var gClient;
var gThreadClient;
Components.utils.import('resource:///modules/devtools/SourceMap.jsm');
// Deep in the complicated labyrinth of code that this test invokes, beneath
// debugger callbacks, sandboxes and nested event loops, lies an exception.
// This exception lay sleeping since the dawn of time, held captive in a
// delicate balance of custom xpcshell error reporters and garbage data about
// the XPCCallContext stack. But bholley dug too greedily, and too deep, and
// awoke shadow and flame in the darkness of nsExternalHelperAppService.cpp.
// We must now trust in deep magic to ensure that it does not awaken again.
ignoreReportedErrors(true);
function run_test()
{
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-source-map");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect(function() {
attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
test_absolute_source_map();
});
});
do_test_pending();
}
function test_absolute_source_map()
{
gClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) {
do_check_eq(aEvent, "newSource");
do_check_eq(aPacket.type, "newSource");
do_check_true(!!aPacket.source);
do_check_true(aPacket.source.url.indexOf("sourcemapped.coffee") !== -1,
"The new source should be a coffee file.");
do_check_eq(aPacket.source.url.indexOf("sourcemapped.js"), -1,
"The new source should not be a js file.");
finishClient(gClient);
});
code = readFile("sourcemapped.js")
+ "\n//# sourceMappingURL=" + getFileUrl("source-map-data/sourcemapped.map");
Components.utils.evalInSandbox(code, gDebuggee, "1.8",
getFileUrl("sourcemapped.js"), 1);
}