1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_sourcemaps-05.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Check that relative source map urls work. 1.9 + */ 1.10 + 1.11 +var gDebuggee; 1.12 +var gClient; 1.13 +var gThreadClient; 1.14 + 1.15 +Components.utils.import('resource:///modules/devtools/SourceMap.jsm'); 1.16 + 1.17 +// Deep in the complicated labyrinth of code that this test invokes, beneath 1.18 +// debugger callbacks, sandboxes and nested event loops, lies an exception. 1.19 +// This exception lay sleeping since the dawn of time, held captive in a 1.20 +// delicate balance of custom xpcshell error reporters and garbage data about 1.21 +// the XPCCallContext stack. But bholley dug too greedily, and too deep, and 1.22 +// awoke shadow and flame in the darkness of nsExternalHelperAppService.cpp. 1.23 +// We must now trust in deep magic to ensure that it does not awaken again. 1.24 +ignoreReportedErrors(true); 1.25 + 1.26 +function run_test() 1.27 +{ 1.28 + initTestDebuggerServer(); 1.29 + gDebuggee = addTestGlobal("test-source-map"); 1.30 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.31 + gClient.connect(function() { 1.32 + attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) { 1.33 + gThreadClient = aThreadClient; 1.34 + test_relative_source_map(); 1.35 + }); 1.36 + }); 1.37 + do_test_pending(); 1.38 +} 1.39 + 1.40 +function test_relative_source_map() 1.41 +{ 1.42 + gClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) { 1.43 + do_check_eq(aEvent, "newSource"); 1.44 + do_check_eq(aPacket.type, "newSource"); 1.45 + do_check_true(!!aPacket.source); 1.46 + 1.47 + do_check_true(aPacket.source.url.indexOf("sourcemapped.coffee") !== -1, 1.48 + "The new source should be a coffee file."); 1.49 + do_check_eq(aPacket.source.url.indexOf("sourcemapped.js"), -1, 1.50 + "The new source should not be a js file."); 1.51 + 1.52 + finishClient(gClient); 1.53 + }); 1.54 + 1.55 + code = readFile("sourcemapped.js") 1.56 + + "\n//# sourceMappingURL=source-map-data/sourcemapped.map"; 1.57 + 1.58 + Components.utils.evalInSandbox(code, gDebuggee, "1.8", 1.59 + getFileUrl("sourcemapped.js"), 1); 1.60 +}