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