REGRESSION (r125912): Crashes in worker tests
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Aug 2012 23:27:45 +0000 (23:27 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Aug 2012 23:27:45 +0000 (23:27 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=94390

        Reviewed by Brady Eidson and Sam Weinig.

        * bindings/js/JSDOMBinding.cpp: (WebCore::reportException): It's always fine
        to report an exception on a worker context, but it's not fine to treat those as windows.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@125946 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBinding.cpp

index e00f6bc..06ebb16 100644 (file)
@@ -1,3 +1,13 @@
+2012-08-17  Alexey Proskuryakov  <ap@apple.com>
+
+        REGRESSION (r125912): Crashes in worker tests
+        https://bugs.webkit.org/show_bug.cgi?id=94390
+
+        Reviewed by Brady Eidson and Sam Weinig.
+
+        * bindings/js/JSDOMBinding.cpp: (WebCore::reportException): It's always fine
+        to report an exception on a worker context, but it's not fine to treat those as windows.
+
 2012-08-17  James Robinson  <jamesr@chromium.org>
 
         [chromium] Add missing header files to .gypi and missing include to CCTiledLayerImpl.cpp
index 0b77332..3ad7c32 100644 (file)
@@ -158,10 +158,13 @@ void reportException(ExecState* exec, JSValue exception)
     if (ExceptionBase* exceptionBase = toExceptionBase(exception))
         errorMessage = stringToUString(exceptionBase->message() + ": "  + exceptionBase->description());
 
-    DOMWindow* activeWindow = activeDOMWindow(exec);
-    if (!activeWindow->isCurrentlyDisplayedInFrame())
-        return;
-    activeWindow->scriptExecutionContext()->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL), 0);
+    JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
+    if (JSDOMWindow* window = jsDynamicCast<JSDOMWindow*>(globalObject)) {
+        if (!window->impl()->isCurrentlyDisplayedInFrame())
+            return;
+    }
+    ScriptExecutionContext* scriptExecutionContext = globalObject->scriptExecutionContext();
+    scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL), 0);
 }
 
 void reportCurrentException(ExecState* exec)