Bug 776389 - Find the source of scripts from the subscript loader correctly. r=bz

This commit is contained in:
Benjamin Peterson 2012-07-22 15:14:47 -07:00
Родитель a0dd3b1be3
Коммит 323dca3e0d
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -3871,6 +3871,12 @@ ReadSourceFromFilename(JSContext *cx, const char *filename, jschar **src, PRUint
{
nsresult rv;
// mozJSSubScriptLoader prefixes the filenames of the scripts it loads with
// the filename of its caller. Axe that if present.
const char *arrow = strstr(filename, " -> ");
if (arrow)
filename = arrow + strlen(" -> ");
// Get the URI.
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), filename);

Просмотреть файл

@ -17,6 +17,7 @@
<script type="application/javascript"><![CDATA[
const Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/Services.jsm");
function inlinefunction() {
return 42;
@ -29,7 +30,11 @@ is(src.charAt(src.length - 1), "}", "inline XUL source should end with '}'");
src = outoflinefunction.toSource();
isnot(src.indexOf("return 42"), -1, "out of line XUL script should have source")
is(src.charAt(src.length - 1), "}", "out of line XUL source should end with '}'");
src = NetUtil.asyncFetch.toSource()
src = NetUtil.asyncFetch.toSource();
isnot(src.indexOf("return"), -1, "JSM should have source");
var ns = {};
Services.scriptloader.loadSubScript("resource://gre/modules/NetUtil.jsm", ns);
src = ns.NetUtil.asyncFetch.toSource();
isnot(src.indexOf("return"), -1, "subscript should have source");
]]></script>
</window>