Bug 1124536 - Fix Debugger UI loadSourceError on PageMod content scripts and bookmarklets associated to 'javascript:SOURCECODE' urls. r=jlongster

This commit is contained in:
Luca Greco 2015-02-13 08:17:00 -05:00
parent 5ecb4705b1
commit b46e0b001d
4 changed files with 73 additions and 0 deletions

View File

@ -86,6 +86,7 @@ support-files =
doc_scope-variable-3.html
doc_scope-variable-4.html
doc_script-eval.html
doc_script-bookmarklet.html
doc_script-switching-01.html
doc_script-switching-02.html
doc_split-console-paused-reload.html
@ -413,6 +414,8 @@ skip-if = e10s && debug
skip-if = e10s && debug
[browser_dbg_sources-sorting.js]
skip-if = e10s && debug
[browser_dbg_sources-bookmarklet.js]
skip-if = e10s && debug
[browser_dbg_split-console-paused-reload.js]
skip-if = e10s && debug
[browser_dbg_stack-01.js]

View File

@ -0,0 +1,50 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Make sure javascript bookmarklet scripts appear and load correctly in the source list
*/
const TAB_URL = EXAMPLE_URL + "doc_script-bookmarklet.html";
const BOOKMARKLET_SCRIPT_CODE = "console.log('bookmarklet executed');";
function test() {
let gTab, gPanel, gDebugger;
let gSources, gBreakpoints;
initDebugger(TAB_URL).then(([aTab,, aPanel]) => {
gTab = aTab;
gPanel = aPanel;
gDebugger = gPanel.panelWin;
gSources = gDebugger.DebuggerView.Sources;
gBreakpoints = gDebugger.DebuggerController.Breakpoints;
return Task.spawn(function*() {
let waitForSource = waitForDebuggerEvents(gPanel, gPanel.panelWin.EVENTS.NEW_SOURCE, 1);
// NOTE: devtools debugger panel needs to be already open,
// or the bookmarklet script will not be shown in the sources panel
callInTab(gTab, "injectBookmarklet", BOOKMARKLET_SCRIPT_CODE);
yield waitForSource;
is(gSources.values.length, 2, "Should have 2 source");
let item = gSources.getItemForAttachment(e => {
return e.label.indexOf("javascript:") === 0;
});
ok(item, "Source label is incorrect.");
let res = yield promiseInvoke(gDebugger.DebuggerController.client,
gDebugger.DebuggerController.client.request,
{ to: item.value, type: "source"});
ok(res && res.source == BOOKMARKLET_SCRIPT_CODE, "SourceActor reply received");
is(res.source, BOOKMARKLET_SCRIPT_CODE, "source is correct");
is(res.contentType, "text/javascript", "contentType is correct");
yield closeDebuggerAndFinish(gPanel);
});
});
}

View File

@ -0,0 +1,14 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Debugger test page</title>
</head>
<body>
<script>function injectBookmarklet(bookmarklet) { setTimeout(function() { window.location = "javascript:" + bookmarklet; }, 0); }</script>
</body>
</html>

View File

@ -5319,6 +5319,12 @@ ThreadSources.prototype = {
}
} catch(ex) {
// Not a valid URI.
// bug 1124536: fix getSourceText on scripts associated "javascript:SOURCE" urls
// (e.g. 'evaluate(sandbox, sourcecode, "javascript:"+sourcecode)' )
if (url.indexOf("javascript:") === 0) {
spec.contentType = "text/javascript";
}
}
}
else {