Reviewed by Maciej & Darin.
Fixes Bug 16868: Gmail crash
and Bug 16871: Crash when loading apple.com/startpage
<http://bugs.webkit.org/show_bug.cgi?id=16868>
<rdar://problem/
5686108>
<http://bugs.webkit.org/show_bug.cgi?id=16871>
<rdar://problem/
5686670>
Adds ActivationImp tear-off for cross-window eval() and fixes an
existing garbage collection issue exposed by the ActivationImp tear-off
patch (r29425) that can occur when an ExecState's m_callingExec is
different than its m_savedExec.
* kjs/ExecState.cpp:
(KJS::ExecState::mark):
* kjs/function.cpp:
(KJS::GlobalFuncImp::callAsFunction):
LayoutTests:
Reviewed by Maciej.
Added a test that checks whether ActivationImp tear-off occurs before
a cross-window eval(). Relevant to
Bug 16868: Gmail crash
<http://bugs.webkit.org/show_bug.cgi?id=16868>
<rdar://problem/
5686108>
* fast/js/window-eval-tearoff-expected.txt: Added.
* fast/js/window-eval-tearoff.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29542
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-01-16 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Maciej & Darin.
+
+ Fixes Bug 16868: Gmail crash
+ and Bug 16871: Crash when loading apple.com/startpage
+
+ <http://bugs.webkit.org/show_bug.cgi?id=16868>
+ <rdar://problem/5686108>
+
+ <http://bugs.webkit.org/show_bug.cgi?id=16871>
+ <rdar://problem/5686670>
+
+ Adds ActivationImp tear-off for cross-window eval() and fixes an
+ existing garbage collection issue exposed by the ActivationImp tear-off
+ patch (r29425) that can occur when an ExecState's m_callingExec is
+ different than its m_savedExec.
+
+ * kjs/ExecState.cpp:
+ (KJS::ExecState::mark):
+ * kjs/function.cpp:
+ (KJS::GlobalFuncImp::callAsFunction):
+
2008-01-16 Sam Weinig <sam@webkit.org>
Reviewed by Oliver.
void ExecState::mark()
{
- for (ExecState* exec = this; exec; exec = exec->m_callingExec)
+ for (ExecState* exec = this; exec; exec = exec->m_callingExec) {
exec->m_scopeChain.mark();
- // FIXME: It is surprising that this code is necessary, since at first
- // glance it seems that all ActivationImps should be in a ScopeChain.
- // However, <http://bugs.webkit.org/show_bug.cgi?id=16871> proves that is
- // not the case.
- if (m_activation && m_activation->isOnStack())
- m_activation->markChildren();
+ if (exec->m_savedExec != exec->m_callingExec && exec->m_savedExec)
+ exec->m_savedExec->mark();
+ }
}
JSGlobalObject* ExecState::lexicalGlobalObject() const
bool switchGlobal = thisObj && thisObj != exec->dynamicGlobalObject() && thisObj->isGlobalObject();
// enter a new execution context
- if (!switchGlobal)
- exec->dynamicGlobalObject()->tearOffActivation(exec);
-
+ exec->dynamicGlobalObject()->tearOffActivation(exec);
JSGlobalObject* globalObject = switchGlobal ? static_cast<JSGlobalObject*>(thisObj) : exec->dynamicGlobalObject();
ExecState newExec(globalObject, evalNode.get(), exec);
+2008-01-16 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Maciej.
+
+ Added a test that checks whether ActivationImp tear-off occurs before
+ a cross-window eval(). Relevant to
+
+ Bug 16868: Gmail crash
+
+ <http://bugs.webkit.org/show_bug.cgi?id=16868>
+ <rdar://problem/5686108>
+
+ * fast/js/window-eval-tearoff-expected.txt: Added.
+ * fast/js/window-eval-tearoff.html: Added.
+
2008-01-16 David Hyatt <hyatt@apple.com>
Update layout tests after fix for <rdar://problem/5681647>.
--- /dev/null
+
+Test that otherWindow.eval() performs ActivationImp tear-off: PASS
--- /dev/null
+<body>
+<script>
+function print(message, color)
+{
+ var paragraph = document.createElement("div");
+ paragraph.appendChild(document.createTextNode(message));
+ paragraph.style.fontFamily = "monospace";
+ if (color)
+ paragraph.style.color = color;
+ document.getElementById("console").appendChild(paragraph);
+}
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+<iframe id=i src='about:blank' width=10 height=10>
+</iframe>
+<div id=console></div>
+<script>
+var otherWindow = document.getElementById('i').contentWindow;
+var closure;
+
+function otherWindowClosure()
+{
+ var localVar = 1;
+
+ return otherWindow.eval("(function () { return localVar; })");
+}
+
+closure = otherWindowClosure();
+
+print("Test that otherWindow.eval() performs ActivationImp tear-off: " + (closure() == 1 ? "PASS" : "FAIL")) ;
+</script>