Use the wrapped global to decide if we are in an xpcshell environment or not (bug 901930). r=vporof

This commit is contained in:
Panos Astithas 2014-02-15 10:57:26 +02:00
Родитель 2ff6e6f32a
Коммит 0e016fbf86
7 изменённых файлов: 46 добавлений и 3 удалений

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

@ -47,6 +47,7 @@ support-files =
doc_frame-parameters.html
doc_function-display-name.html
doc_function-search.html
doc_global-method-override.html
doc_iframes.html
doc_included-script.html
doc_inline-debugger-statement.html
@ -122,6 +123,7 @@ support-files =
[browser_dbg_event-listeners.js]
[browser_dbg_file-reload.js]
[browser_dbg_function-display-name.js]
[browser_dbg_global-method-override.js]
[browser_dbg_globalactor.js]
[browser_dbg_host-layout.js]
[browser_dbg_iframes.js]

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

@ -0,0 +1,20 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests that scripts that override properties of the global object, like
* toString don't break the debugger. The test page used to cause the debugger
* to throw when trying to attach to the thread actor.
*/
const TAB_URL = EXAMPLE_URL + "doc_global-method-override.html";
function test() {
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
let gDebugger = aPanel.panelWin;
ok(gDebugger, "Should have a debugger available.");
is(gDebugger.gThreadClient.state, "attached", "Debugger should be attached.");
closeDebuggerAndFinish(aPanel);
});
}

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

@ -0,0 +1,16 @@
<!-- 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 global method override test page</title>
</head>
<body>
<script type="text/javascript">
console.log( "Error: " + toString( { x: 0, y: 0 } ) );
function toString(v) { return "[ " + v.x + ", " + v.y + " ]"; }
</script>
</body>
</html>

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

@ -436,7 +436,10 @@ function ThreadActor(aHooks, aGlobal)
this._state = "detached";
this._frameActors = [];
this._hooks = aHooks;
this.global = aGlobal;
this.global = this.globalSafe = aGlobal;
if (aGlobal && aGlobal.wrappedJSObject) {
this.global = aGlobal.wrappedJSObject;
}
// A map of actorID -> actor for breakpoints created and managed by the server.
this._hiddenBreakpoints = new Map();
@ -1763,7 +1766,7 @@ ThreadActor.prototype = {
// Clear DOM event breakpoints.
// XPCShell tests don't use actual DOM windows for globals and cause
// removeListenerForAllEvents to throw.
if (this.global && !this.global.toString().contains("Sandbox")) {
if (this.globalSafe && !this.globalSafe.toString().contains("Sandbox")) {
let els = Cc["@mozilla.org/eventlistenerservice;1"]
.getService(Ci.nsIEventListenerService);
els.removeListenerForAllEvents(this.global, this._allEventsListener, true);

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

@ -655,7 +655,7 @@ BrowserTabActor.prototype = {
this._contextPool = new ActorPool(this.conn);
this.conn.addActorPool(this._contextPool);
this.threadActor = new ThreadActor(this, this.window.wrappedJSObject);
this.threadActor = new ThreadActor(this, this.window);
this._contextPool.addActor(this.threadActor);
},

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

@ -57,6 +57,7 @@ function TestTabActor(aConnection, aGlobal)
{
this.conn = aConnection;
this._global = aGlobal;
this._global.wrappedJSObject = aGlobal;
this._threadActor = new ThreadActor(this, this._global);
this.conn.addActor(this._threadActor);
this._attached = false;

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

@ -113,5 +113,6 @@ function createRootActor()
DebuggerServer.addTestGlobal = function addTestGlobal(aGlobal)
{
aGlobal.wrappedJSObject = aGlobal;
gTestGlobals.push(aGlobal);
}