mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 837060: Test that Debugger.Object.prototype.evalInGlobal{,withBindings} properly outerizes 'this'. r=jorendorff
This commit is contained in:
parent
0372a35086
commit
6a035ba327
@ -28,3 +28,4 @@ support-files =
|
||||
[test_styles-matched.html]
|
||||
[test_styles-modify.html]
|
||||
[test_unsafeDereference.html]
|
||||
[test_evalInGlobal-outerized_this.html]
|
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=837060
|
||||
|
||||
When we use Debugger.Object.prototype.evalInGlobal, the 'this' value seen
|
||||
by the evaluated code should be the WindowProxy, not the inner window
|
||||
object.
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mozilla Bug 837060</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
||||
window.onload = function () {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = "data:text/html,<script>var me = 'page 1';<\/script>";
|
||||
iframe.onload = firstOnLoadHandler;
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
function firstOnLoadHandler() {
|
||||
var dbg = new Debugger;
|
||||
var page1DO = dbg.addDebuggee(iframe.contentWindow);
|
||||
iframe.src = "data:text/html,<script>var me = 'page 2';<\/script>";
|
||||
iframe.onload = function () {
|
||||
var page2DO = dbg.addDebuggee(iframe.contentWindow);
|
||||
ok(page1DO !== page2DO, "the two pages' globals get distinct D.O's");
|
||||
ok(page1DO.unsafeDereference() === page2DO.unsafeDereference(),
|
||||
"unwrapping page1DO and page2DO outerizes both, yielding the same outer window");
|
||||
|
||||
is(page1DO.evalInGlobal('me').return, 'page 1', "page1DO continues to refer to original page");
|
||||
is(page2DO.evalInGlobal('me').return, 'page 2', "page2DO refers to current page");
|
||||
|
||||
is(page1DO.evalInGlobal('this === window').return, true,
|
||||
"page 1: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
|
||||
is(page1DO.evalInGlobalWithBindings('this === window', {x:2}).return, true,
|
||||
"page 1: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
|
||||
|
||||
is(page2DO.evalInGlobal('this === window').return, true,
|
||||
"page 2: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
|
||||
is(page2DO.evalInGlobalWithBindings('this === window', {x:2}).return, true,
|
||||
"page 2: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
|
||||
|
||||
// Debugger doesn't let one use outer windows as globals. You have to innerize.
|
||||
var outerDO = page1DO.makeDebuggeeValue(page1DO.unsafeDereference());
|
||||
ok(outerDO !== page1DO, "outer window gets its own D.O, distinct from page 1's global");
|
||||
ok(outerDO !== page2DO, "outer window gets its own D.O, distinct from page 2's global");
|
||||
SimpleTest.doesThrow(function () { outerDO.evalInGlobal('me'); },
|
||||
"outer window D.Os can't be used as globals");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user