Title: [278520] trunk
Revision
278520
Author
[email protected]
Date
2021-06-04 21:39:39 -0700 (Fri, 04 Jun 2021)

Log Message

Worker.constructor throws an exception when the url param is an empty string
https://bugs.webkit.org/show_bug.cgi?id=226637

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline WPT test now that it is passing.

* web-platform-tests/workers/constructors/Worker/Worker-constructor-expected.txt:

Source/WebCore:

Stop throwing an exception if the Worker constructor gets called with an empty string.
Instead treat it as a relative URL, like Chrome and Firefox do.

No new tests, updated existing ones.

* workers/AbstractWorker.cpp:
(WebCore::AbstractWorker::resolveURL):

LayoutTests:

Update existing tests to reflect behavior change.

* fast/workers/worker-constructor-expected.txt:
* fast/workers/worker-constructor.html:
* http/tests/workers/worker-invalid-url-expected.txt:
* http/tests/workers/worker-invalid-url.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278519 => 278520)


--- trunk/LayoutTests/ChangeLog	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/LayoutTests/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
@@ -1,3 +1,17 @@
+2021-06-04  Chris Dumez  <[email protected]>
+
+        Worker.constructor throws an exception when the url param is an empty string
+        https://bugs.webkit.org/show_bug.cgi?id=226637
+
+        Reviewed by Darin Adler.
+
+        Update existing tests to reflect behavior change.
+
+        * fast/workers/worker-constructor-expected.txt:
+        * fast/workers/worker-constructor.html:
+        * http/tests/workers/worker-invalid-url-expected.txt:
+        * http/tests/workers/worker-invalid-url.html:
+
 2021-06-04  Diego Pino Garcia  <[email protected]>
 
         [GLIB][GTK] Unreviewed test gardening. Remove flaky tests that have been constantly passing for the last 4000 revisions.

Modified: trunk/LayoutTests/fast/workers/worker-constructor-expected.txt (278519 => 278520)


--- trunk/LayoutTests/fast/workers/worker-constructor-expected.txt	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/LayoutTests/fast/workers/worker-constructor-expected.txt	2021-06-05 04:39:39 UTC (rev 278520)
@@ -1,9 +1,10 @@
+CONSOLE MESSAGE: SyntaxError: Unexpected token '<'
 Test Worker constructor functionality. Should print a series of PASS messages, followed with DONE.
 
 PASS: toString exception propagated correctly.
 PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded.)
 PASS: invoking Worker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
-PASS: invoking Worker constructor with empty script URL resulted in an exception (SyntaxError: The string did not match the expected pattern.)
+PASS: onerror invoked for an empty script URL.
 PASS: invoking Worker constructor with invalid script URL resulted in an exception (SyntaxError: The string did not match the expected pattern.)
 PASS: onerror invoked for a script that could not be loaded.
 PASS: Successfully created worker.

Modified: trunk/LayoutTests/fast/workers/worker-constructor.html (278519 => 278520)


--- trunk/LayoutTests/fast/workers/worker-constructor.html	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/LayoutTests/fast/workers/worker-constructor.html	2021-06-05 04:39:39 UTC (rev 278520)
@@ -72,11 +72,11 @@
     try {
         var worker = new Worker("");
         worker._onerror_ = function() {
-            log("FAIL: onerror invoked for an empty script URL.");
+            log("PASS: onerror invoked for an empty script URL.");
             runNextTest();
         }
     } catch (ex) {
-        log("PASS: invoking Worker constructor with empty script URL resulted in an exception (" + ex + ")");
+        log("FAIL: invoking Worker constructor with empty script URL resulted in an exception (" + ex + ")");
         runNextTest();
     }
 }

Modified: trunk/LayoutTests/http/tests/workers/worker-invalid-url-expected.txt (278519 => 278520)


--- trunk/LayoutTests/http/tests/workers/worker-invalid-url-expected.txt	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/LayoutTests/http/tests/workers/worker-invalid-url-expected.txt	2021-06-05 04:39:39 UTC (rev 278520)
@@ -1,5 +1,4 @@
-Test worker invalid url exceptions. Should print two "PASS" statements.
+Test worker invalid url exceptions. Should print one "PASS" statement.
 
 PASS: Got security error.
-PASS: Got syntax error.
 

Modified: trunk/LayoutTests/http/tests/workers/worker-invalid-url.html (278519 => 278520)


--- trunk/LayoutTests/http/tests/workers/worker-invalid-url.html	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/LayoutTests/http/tests/workers/worker-invalid-url.html	2021-06-05 04:39:39 UTC (rev 278520)
@@ -1,6 +1,6 @@
 <html>
 <body>
-<p>Test worker invalid url exceptions. Should print two "PASS" statements.</p>
+<p>Test worker invalid url exceptions. Should print one "PASS" statement.</p>
 <div id=result></div>
 <script>
 if (window.testRunner)
@@ -20,16 +20,6 @@
     else
         log("FAIL: Got error code " + error.code + ". Expected error code 18.");
 }
-
-try {
-    new Worker("");
-    log("FAIL: No exception throw when accessing an invalid url.");
-} catch (error) {
-    if (error.code == 12)
-        log("PASS: Got syntax error.");
-    else
-        log("FAIL: Got error code " + error.code + ". Expected error code 12.");
-}
 </script>
 </body>
 </html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (278519 => 278520)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
@@ -1,3 +1,14 @@
+2021-06-04  Chris Dumez  <[email protected]>
+
+        Worker.constructor throws an exception when the url param is an empty string
+        https://bugs.webkit.org/show_bug.cgi?id=226637
+
+        Reviewed by Darin Adler.
+
+        Rebaseline WPT test now that it is passing.
+
+        * web-platform-tests/workers/constructors/Worker/Worker-constructor-expected.txt:
+
 2021-06-04  Alex Christensen  <[email protected]>
 
         Implement off-by-default experimental feature for PerformanceResourceTiming.transferSize, encodedBodySize, and decodedBodySize

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/workers/constructors/Worker/Worker-constructor-expected.txt (278519 => 278520)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/workers/constructors/Worker/Worker-constructor-expected.txt	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/workers/constructors/Worker/Worker-constructor-expected.txt	2021-06-05 04:39:39 UTC (rev 278520)
@@ -2,7 +2,7 @@
 PASS Test toString propagation exception.
 PASS Test recursive Worker creation.
 PASS Test worker creation with no arguments
-FAIL Test Worker creation with empty script URL. The string did not match the expected pattern.
+PASS Test Worker creation with empty script URL.
 PASS Test invalid script URL.
 PASS Test not existent script URL.
 PASS Test the Worker object defines postMessage() and addEventListener().

Modified: trunk/Source/WebCore/ChangeLog (278519 => 278520)


--- trunk/Source/WebCore/ChangeLog	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/Source/WebCore/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
@@ -1,5 +1,20 @@
 2021-06-04  Chris Dumez  <[email protected]>
 
+        Worker.constructor throws an exception when the url param is an empty string
+        https://bugs.webkit.org/show_bug.cgi?id=226637
+
+        Reviewed by Darin Adler.
+
+        Stop throwing an exception if the Worker constructor gets called with an empty string.
+        Instead treat it as a relative URL, like Chrome and Firefox do.
+
+        No new tests, updated existing ones.
+
+        * workers/AbstractWorker.cpp:
+        (WebCore::AbstractWorker::resolveURL):
+
+2021-06-04  Chris Dumez  <[email protected]>
+
         Unreviewed Windows build fix after r278516.
 
         * platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp:

Modified: trunk/Source/WebCore/workers/AbstractWorker.cpp (278519 => 278520)


--- trunk/Source/WebCore/workers/AbstractWorker.cpp	2021-06-05 02:21:10 UTC (rev 278519)
+++ trunk/Source/WebCore/workers/AbstractWorker.cpp	2021-06-05 04:39:39 UTC (rev 278520)
@@ -42,9 +42,6 @@
 
 ExceptionOr<URL> AbstractWorker::resolveURL(const String& url, bool shouldBypassMainWorldContentSecurityPolicy)
 {
-    if (url.isEmpty())
-        return Exception { SyntaxError };
-
     auto& context = *scriptExecutionContext();
 
     // FIXME: This should use the dynamic global scope (bug #27887).
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to