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

--HG--
extra : rebase_source : 1eed084501992ced4bf038c6efda0b9058214f59
This commit is contained in:
Jim Blandy 2017-05-15 13:45:05 -07:00
Родитель 88e5d07280
Коммит 495a9fc5b2
5 изменённых файлов: 45 добавлений и 5 удалений

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

@ -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`.

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

@ -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.

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

@ -0,0 +1,10 @@
// 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);

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

@ -0,0 +1,11 @@
// 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);

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

@ -0,0 +1,11 @@
// 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);