Worker.importScript() should clean errors for cross origin imports.
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 00:48:28 +0000 (00:48 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 00:48:28 +0000 (00:48 +0000)
commitb4d2868b9c78afe43be13f991bd7a3d3f13fab29
treeabb00c77f0f9ab0a9b4216b2427186058d33c272
parent789179e122dd5339fc586748a546699cd3dbf742
Worker.importScript() should clean errors for cross origin imports.
https://bugs.webkit.org/show_bug.cgi?id=52871

Reviewed by Adam Barth and Oliver Hunt.

Source/WebCore:

Test: http/tests/workers/worker-importScriptsOnError.html

* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::evaluate): Use sanitizeScriptError
to determine when to create a clean exception.
* bindings/v8/WorkerContextExecutionProxy.cpp:
(WebCore::WorkerContextExecutionProxy::evaluate): Ditto.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::sanitizeScriptError): Figure out
if the error needs to be cleaned up.
(WebCore::ScriptExecutionContext::dispatchErrorEvent): Extracted
sanitizeScriptError for use by other places.
* dom/ScriptExecutionContext.h:
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::importScripts): Use the reponse url when
telling the evaluate where the script came fro.
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::responseURL): Expose the url that
the script was loaded from (which may be different from url() due
to redirects).
(WebCore::WorkerScriptLoader::didReceiveResponse): Capture the reponse url.
* workers/WorkerScriptLoader.h:

LayoutTests:

* http/tests/workers/resources/worker-importScripts-error.js: Added.
* http/tests/workers/resources/worker-importScripts-throw.js: Added.
* http/tests/workers/worker-importScriptsOnError.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@77563 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/resources/worker-importScripts-error.js [new file with mode: 0644]
LayoutTests/http/tests/workers/resources/worker-importScripts-throw.js [new file with mode: 0644]
LayoutTests/http/tests/workers/worker-importScriptsOnError-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/worker-importScriptsOnError.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/workers/WorkerContext.cpp
Source/WebCore/workers/WorkerScriptLoader.cpp
Source/WebCore/workers/WorkerScriptLoader.h