From 1eceb876b2b6ea88885196bbcecf6cd63f19e9af Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sat, 2 Oct 2004 16:11:57 +0000 Subject: [PATCH] Try to keep window.arguments from being wiped out by scope-clearing by setting the document in the window to null before setting window.arguments in AttachArguments. Bug 25040, r=danm, sr=jst git-svn-id: svn://10.0.0.236/trunk@163138 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/windowwatcher/src/nsWindowWatcher.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 7372d6511f3..c040dac7376 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -1683,6 +1683,15 @@ nsWindowWatcher::AttachArguments(nsIDOMWindow *aWindow, JSObject *args; args = ::JS_NewArrayObject(cx, argc, argv); if (args) { + // If this is an existing window that we're opening into, the document + // change in it will wipe out the JS scope. In particular it would clear + // the "arguments" property we're about to set. So set the document in + // the window to null right away, so that when the new document loads we + // don't clear the scope. + nsCOMPtr globalObject(do_GetInterface(aWindow)); + if (globalObject) { + globalObject->SetNewDocument(nsnull, PR_TRUE, PR_TRUE); + } jsval argsVal = OBJECT_TO_JSVAL(args); // ::JS_DefineProperty(cx, window_obj, "arguments", // argsVal, NULL, NULL, JSPROP_PERMANENT);