Web Worker fails to fire error event when a resource fetch fails.
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2011 00:21:23 +0000 (00:21 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2011 00:21:23 +0000 (00:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=62475

Reviewed by Dmitry Titov.

Source/WebCore:

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

* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::didFinishLoading): Ensure that
the client is notified of the error when it happens during loading.

LayoutTests:

* http/tests/workers/worker-workerScriptNotThere-expected.txt: Added.
* http/tests/workers/worker-workerScriptNotThere.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/workers/worker-workerScriptNotThere-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/worker-workerScriptNotThere.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/workers/WorkerScriptLoader.cpp

index b367bc1..605bf44 100644 (file)
@@ -2,6 +2,16 @@
 
         Reviewed by Dmitry Titov.
 
+        Web Worker fails to fire error event when a resource fetch fails.
+        https://bugs.webkit.org/show_bug.cgi?id=62475
+
+        * http/tests/workers/worker-workerScriptNotThere-expected.txt: Added.
+        * http/tests/workers/worker-workerScriptNotThere.html: Added.
+
+2011-06-10  David Levin  <levin@chromium.org>
+
+        Reviewed by Dmitry Titov.
+
         Fetching a Worker with url that isn't allowed from a file based test causes DRT to crash.
         https://bugs.webkit.org/show_bug.cgi?id=62469
 
diff --git a/LayoutTests/http/tests/workers/worker-workerScriptNotThere-expected.txt b/LayoutTests/http/tests/workers/worker-workerScriptNotThere-expected.txt
new file mode 100644 (file)
index 0000000..806443e
--- /dev/null
@@ -0,0 +1,8 @@
+Test worker file does not exist error. Should print two "PASS" statements followed by "DONE".
+
+The order of the error events should be onerror and then error event, and this test should be improved to verify that when bug https://bugs.webkit.org/show_bug.cgi?id=62485 is fixed.
+
+PASS: error event.
+PASS: onerror called.
+DONE
+
diff --git a/LayoutTests/http/tests/workers/worker-workerScriptNotThere.html b/LayoutTests/http/tests/workers/worker-workerScriptNotThere.html
new file mode 100644 (file)
index 0000000..1d89a6a
--- /dev/null
@@ -0,0 +1,51 @@
+<html>
+<body>
+<p>Test worker file does not exist error. Should print two "PASS" statements followed by "DONE".</p>
+<p>The order of the error events should be onerror and then error event, and this test should be improved to verify that when bug https://bugs.webkit.org/show_bug.cgi?id=62485 is fixed.</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+function log(message)
+{
+    document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function done()
+{
+    log("DONE");
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+var eventCount = 0;
+
+function eventDone()
+{
+    eventCount++;
+    if (eventCount == 2)
+        done();
+}
+
+var worker;
+try {
+    worker = new Worker("this-file-does-should-not-exist.js");
+} catch (error) {
+    log("FAIL: Exception thrown.");
+}
+
+worker.addEventListener('error', function(error) {
+    log("PASS: error event.");
+    eventDone();
+}, false);
+
+worker.onerror =  function(error) {
+    log("PASS: onerror called.");
+    eventDone();
+};
+
+</script>
+</body>
+</html>
index f8090f7..efce7c2 100644 (file)
@@ -2,6 +2,19 @@
 
         Reviewed by Dmitry Titov.
 
+        Web Worker fails to fire error event when a resource fetch fails.
+        https://bugs.webkit.org/show_bug.cgi?id=62475
+
+        Test: http/tests/workers/worker-workerScriptNotThere.html
+
+        * workers/WorkerScriptLoader.cpp:
+        (WebCore::WorkerScriptLoader::didFinishLoading): Ensure that
+        the client is notified of the error when it happens during loading.
+
+2011-06-10  David Levin  <levin@chromium.org>
+
+        Reviewed by Dmitry Titov.
+
         Fetching a Worker with url that isn't allowed from a file based test causes DRT to crash.
         https://bugs.webkit.org/show_bug.cgi?id=62469
 
index e41548a..c7a57e5 100644 (file)
@@ -146,8 +146,10 @@ void WorkerScriptLoader::didReceiveData(const char* data, int len)
 
 void WorkerScriptLoader::didFinishLoading(unsigned long identifier, double)
 {
-    if (m_failed)
+    if (m_failed) {
+        notifyError();
         return;
+    }
 
     if (m_decoder)
         m_script += m_decoder->flush();