Commit 495a9fc5 authored by Jim Blandy's avatar Jim Blandy
Browse files

Bug 1297466 - Doc fixes and tests for Debugger.Script.prototype.url,...

Bug 1297466 - Doc fixes and tests for Debugger.Script.prototype.url, Debugger.Source.prototype.url. r=shu

--HG--
extra : rebase_source : 1eed084501992ced4bf038c6efda0b9058214f59
parent 88e5d072
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -125,8 +125,12 @@ from its prototype:

`url`
:   **If the instance refers to a `JSScript`**, the filename or URL from which
    this script's code was loaded. If the `source` property is non-`null`,
    then this is equal to `source.url`.
    this script's code was loaded. For scripts created by `eval` or the
    `Function` constructor, this may be a synthesized filename, starting with a
    valid URL and followed by information tracking how the code was introduced
    into the system; the entire string is not a valid URL. For
    `Function.prototype`'s script, this is `null`. If this `Debugger.Script`'s
    `source` property is non-`null`, then this is equal to `source.url`.

    **If the instance refers to WebAssembly code**, throw a `TypeError`.

+7 −3
Original line number Diff line number Diff line
@@ -85,9 +85,13 @@ from its prototype:
    WebAssembly bytecode.

`url`
:   **If the instance refers to JavaScript source**, the URL from which this
    source was loaded, if this source was loaded from a URL. Otherwise, this
    is `undefined`. Source may be loaded from a URL in the following ways:
:   **If the instance refers to JavaScript source**, the filename or URL from
    which this script's code was loaded. For scripts created by `eval` or the
    `Function` constructor, this may be a synthesized filename, starting with a
    valid URL and followed by information tracking how the code was introduced
    into the system; the entire string is not a valid URL. For
    `Function.prototype`'s script, this is `null`. Source may be loaded from a
    URL in the following ways:

    * The URL may appear as the `src` attribute of a `<script>` element
      in markup text.
+10 −0
Original line number Diff line number Diff line
// Source.prototype.url returns a synthesized URL for eval code.

var g = newGlobal();
g.eval('function double() { return 2*x }');

var dbg = new Debugger;
var gw = dbg.addDebuggee(g);

var fw = gw.getOwnPropertyDescriptor('double').value;
assertEq(!!fw.script.source.url.match(/Source-url-01.js line [0-9]+ > eval/), true);
+11 −0
Original line number Diff line number Diff line
// Source.prototype.url returns a synthesized URL for Function code.

var g = newGlobal();
g.eval('var double = Function("x", "return 2*x;");');

var dbg = new Debugger;
var gw = dbg.addDebuggee(g);

var fw = gw.getOwnPropertyDescriptor('double').value;
print(fw.script.source.url);
assertEq(!!fw.script.source.url.match(/Source-url-02.js .* > Function/), true);
+11 −0
Original line number Diff line number Diff line
// Source.prototype.url is null for Function.prototype.

var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);

var Fpw = gw.getOwnPropertyDescriptor('Function').value.proto;
assertEq(Fpw.script.source.url, null);