Changeset 278520 in webkit


Ignore:
Timestamp:
Jun 4, 2021, 9:39:39 PM (4 years ago)
Author:
Chris Dumez
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:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r278519 r278520  
     12021-06-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Worker.constructor throws an exception when the url param is an empty string
     4        https://bugs.webkit.org/show_bug.cgi?id=226637
     5
     6        Reviewed by Darin Adler.
     7
     8        Update existing tests to reflect behavior change.
     9
     10        * fast/workers/worker-constructor-expected.txt:
     11        * fast/workers/worker-constructor.html:
     12        * http/tests/workers/worker-invalid-url-expected.txt:
     13        * http/tests/workers/worker-invalid-url.html:
     14
    1152021-06-04  Diego Pino Garcia  <dpino@igalia.com>
    216
  • trunk/LayoutTests/fast/workers/worker-constructor-expected.txt

    r219663 r278520  
     1CONSOLE MESSAGE: SyntaxError: Unexpected token '<'
    12Test Worker constructor functionality. Should print a series of PASS messages, followed with DONE.
    23
     
    45PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded.)
    56PASS: invoking Worker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
    6 PASS: invoking Worker constructor with empty script URL resulted in an exception (SyntaxError: The string did not match the expected pattern.)
     7PASS: onerror invoked for an empty script URL.
    78PASS: invoking Worker constructor with invalid script URL resulted in an exception (SyntaxError: The string did not match the expected pattern.)
    89PASS: onerror invoked for a script that could not be loaded.
  • trunk/LayoutTests/fast/workers/worker-constructor.html

    r124680 r278520  
    7373        var worker = new Worker("");
    7474        worker.onerror = function() {
    75             log("FAIL: onerror invoked for an empty script URL.");
     75            log("PASS: onerror invoked for an empty script URL.");
    7676            runNextTest();
    7777        }
    7878    } catch (ex) {
    79         log("PASS: invoking Worker constructor with empty script URL resulted in an exception (" + ex + ")");
     79        log("FAIL: invoking Worker constructor with empty script URL resulted in an exception (" + ex + ")");
    8080        runNextTest();
    8181    }
  • trunk/LayoutTests/http/tests/workers/worker-invalid-url-expected.txt

    r88575 r278520  
    1 Test worker invalid url exceptions. Should print two "PASS" statements.
     1Test worker invalid url exceptions. Should print one "PASS" statement.
    22
    33PASS: Got security error.
    4 PASS: Got syntax error.
    54
  • trunk/LayoutTests/http/tests/workers/worker-invalid-url.html

    r120167 r278520  
    11<html>
    22<body>
    3 <p>Test worker invalid url exceptions. Should print two "PASS" statements.</p>
     3<p>Test worker invalid url exceptions. Should print one "PASS" statement.</p>
    44<div id=result></div>
    55<script>
     
    2121        log("FAIL: Got error code " + error.code + ". Expected error code 18.");
    2222}
    23 
    24 try {
    25     new Worker("");
    26     log("FAIL: No exception throw when accessing an invalid url.");
    27 } catch (error) {
    28     if (error.code == 12)
    29         log("PASS: Got syntax error.");
    30     else
    31         log("FAIL: Got error code " + error.code + ". Expected error code 12.");
    32 }
    3323</script>
    3424</body>
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r278477 r278520  
     12021-06-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Worker.constructor throws an exception when the url param is an empty string
     4        https://bugs.webkit.org/show_bug.cgi?id=226637
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline WPT test now that it is passing.
     9
     10        * web-platform-tests/workers/constructors/Worker/Worker-constructor-expected.txt:
     11
    1122021-06-04  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/constructors/Worker/Worker-constructor-expected.txt

    r267649 r278520  
    33PASS Test recursive Worker creation.
    44PASS Test worker creation with no arguments
    5 FAIL Test Worker creation with empty script URL. The string did not match the expected pattern.
     5PASS Test Worker creation with empty script URL.
    66PASS Test invalid script URL.
    77PASS Test not existent script URL.
  • trunk/Source/WebCore/ChangeLog

    r278518 r278520  
     12021-06-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Worker.constructor throws an exception when the url param is an empty string
     4        https://bugs.webkit.org/show_bug.cgi?id=226637
     5
     6        Reviewed by Darin Adler.
     7
     8        Stop throwing an exception if the Worker constructor gets called with an empty string.
     9        Instead treat it as a relative URL, like Chrome and Firefox do.
     10
     11        No new tests, updated existing ones.
     12
     13        * workers/AbstractWorker.cpp:
     14        (WebCore::AbstractWorker::resolveURL):
     15
    1162021-06-04  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebCore/workers/AbstractWorker.cpp

    r243887 r278520  
    4343ExceptionOr<URL> AbstractWorker::resolveURL(const String& url, bool shouldBypassMainWorldContentSecurityPolicy)
    4444{
    45     if (url.isEmpty())
    46         return Exception { SyntaxError };
    47 
    4845    auto& context = *scriptExecutionContext();
    4946
Note: See TracChangeset for help on using the changeset viewer.