Changeset 281472 in webkit


Ignore:
Timestamp:
Aug 23, 2021 2:39:37 PM (11 months ago)
Author:
commit-queue@webkit.org
Message:

Setting window.location.href to an invalid URL should throw a TypeError
https://bugs.webkit.org/show_bug.cgi?id=229303

Patch by Alex Christensen <achristensen@webkit.org> on 2021-08-23
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

  • web-platform-tests/url/failure-expected.txt:

Source/WebCore:

This matches Firefox and the specification, and Chrome also throws an exception in this case.

  • page/Location.cpp:

(WebCore::Location::setLocation):

LayoutTests:

  • fast/dom/location-new-window-no-crash-expected.txt:
  • fast/dom/location-new-window-no-crash.html:
  • fast/loader/file-URL-with-port-number.html:
  • fast/loader/location-port.html:
  • fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt:
  • fast/loader/redirect-to-invalid-url-using-javascript-disallowed.html:
  • fast/url/navigate-non-ascii.html:
  • platform/ios-wk1/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt: Removed.
  • platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt: Removed.
Location:
trunk
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r281471 r281472  
     12021-08-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        Setting window.location.href to an invalid URL should throw a TypeError
     4        https://bugs.webkit.org/show_bug.cgi?id=229303
     5
     6        Reviewed by Chris Dumez.
     7
     8        * fast/dom/location-new-window-no-crash-expected.txt:
     9        * fast/dom/location-new-window-no-crash.html:
     10        * fast/loader/file-URL-with-port-number.html:
     11        * fast/loader/location-port.html:
     12        * fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt:
     13        * fast/loader/redirect-to-invalid-url-using-javascript-disallowed.html:
     14        * fast/url/navigate-non-ascii.html:
     15        * platform/ios-wk1/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt: Removed.
     16        * platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt: Removed.
     17
    1182021-08-23  Ayumi Kojima  <ayumi_kojima@apple.com>
    219
  • trunk/LayoutTests/fast/dom/location-new-window-no-crash-expected.txt

    r43014 r281472  
    1515PASS testWindow.location.href = 'data:text/plain,b' is 'data:text/plain,b'
    1616PASS testWindow.location.protocol = 'data' is 'data'
    17 PASS testWindow.location.host = 'c' is 'c'
    18 PASS testWindow.location.hostname = 'd' is 'd'
    19 PASS testWindow.location.port = 'e' is 'e'
    20 PASS testWindow.location.pathname = 'f' is 'f'
    21 PASS testWindow.location.search = 'g' is 'g'
     17PASS testWindow.location.host = 'c' threw exception TypeError: Invalid URL.
     18PASS testWindow.location.hostname = 'd' threw exception TypeError: Invalid URL.
     19PASS testWindow.location.port = 'e' threw exception TypeError: Invalid URL.
     20PASS testWindow.location.pathname = 'f' threw exception TypeError: Invalid URL.
     21PASS testWindow.location.search = 'g' threw exception TypeError: Invalid URL.
    2222PASS testWindow.location.hash = 'h' is 'h'
    2323PASS testWindow.location.assign('data:text/plain,i') is undefined
  • trunk/LayoutTests/fast/dom/location-new-window-no-crash.html

    r217390 r281472  
    3131shouldBe("testWindow.location.href = 'data:text/plain,b'", "'data:text/plain,b'");
    3232shouldBe("testWindow.location.protocol = 'data'", "'data'"); // Firefox throws an exception
    33 shouldBe("testWindow.location.host = 'c'", "'c'"); // Firefox throws an exception
    34 shouldBe("testWindow.location.hostname = 'd'", "'d'"); // Firefox throws an exception
    35 shouldBe("testWindow.location.port = 'e'", "'e'"); // Firefox throws an exception
    36 shouldBe("testWindow.location.pathname = 'f'", "'f'"); // Firefox throws an exception
    37 shouldBe("testWindow.location.search = 'g'", "'g'");
     33shouldThrow("testWindow.location.host = 'c'");
     34shouldThrow("testWindow.location.hostname = 'd'");
     35shouldThrow("testWindow.location.port = 'e'");
     36shouldThrow("testWindow.location.pathname = 'f'");
     37shouldThrow("testWindow.location.search = 'g'");
    3838shouldBe("testWindow.location.hash = 'h'", "'h'");
    3939
  • trunk/LayoutTests/fast/loader/file-URL-with-port-number.html

    r268479 r281472  
    3939    subframe.onload = subframeLoaded;
    4040    subframe.onerror = subframeError;
    41     subframe.contentWindow.location = subframeLocation;
     41    try {
     42        subframe.contentWindow.location = subframeLocation;
     43    } catch (e) { }
    4244    setTimeout(subframeDidNotLoad, 100);
    4345}
  • trunk/LayoutTests/fast/loader/location-port.html

    r207162 r281472  
    3636        shouldBe('internalFrame.contentWindow.location.port == ""', true);
    3737
    38         internalFrame.contentWindow.location.port = 80;
     38        try {
     39            internalFrame.contentWindow.location.port = 80;
     40        } catch (e) { }
    3941        setTimeout(checkTest3, 300);
    4042    }
     
    4446        shouldBe('internalFrame.contentWindow.location.port == ""', true);
    4547
    46         internalFrame.contentWindow.location.port = 0;
     48        try {
     49            internalFrame.contentWindow.location.port = 0;
     50        } catch (e) { }
    4751        setTimeout(checkTest4, 300);
    4852    }
     
    6771        shouldBe('internalFrame.contentWindow.location.port == ""', true);
    6872
    69         internalFrame.contentWindow.location.port = 88;
     73        try {
     74            internalFrame.contentWindow.location.port = 88;
     75        } catch (e) { }
    7076        setTimeout(checkTest1, 300);
    7177    };
  • trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt

    r267644 r281472  
    11main frame - didFinishDocumentLoadForFrame
    2 main frame - willPerformClientRedirectToURL: http://A=a%B=b
    32main frame - didHandleOnloadEventsForFrame
    43main frame - didFinishLoadForFrame
    5 main frame - didCancelClientRedirectForFrame
    64Tests that we do not redirect to an invalid URL initiated by JavaScript. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
    75
     
    97
    108
    11 PASS testRunner.didCancelClientRedirect became true
     9PASS caughtException is true
    1210PASS successfullyParsed is true
    1311
  • trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-javascript-disallowed.html

    r229341 r281472  
    1212<script>
    1313description("Tests that we do not redirect to an invalid URL initiated by JavaScript. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.");
     14var caughtException = false;
    1415onload = function() {
    15     window.location.href = "http://A=a%B=b";
    16     shouldBecomeEqual("testRunner.didCancelClientRedirect", "true", finishJSTest);
     16    try {
     17        window.location.href = "http://A=a%B=b";
     18    } catch (e) {
     19        caughtException = true;
     20    }
     21    shouldBe("caughtException", "true");
     22    finishJSTest();
    1723}
    1824</script>
  • trunk/LayoutTests/fast/url/navigate-non-ascii.html

    r263475 r281472  
    11<script>
    2 location.assign('//\u2000');
     2try {
     3    location.assign('//\u2000');
     4} catch (e) { }
    35testRunner.waitUntilDone();
    46testRunner.dumpAsText();
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r281470 r281472  
     12021-08-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        Setting window.location.href to an invalid URL should throw a TypeError
     4        https://bugs.webkit.org/show_bug.cgi?id=229303
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/url/failure-expected.txt:
     9
    1102021-08-23  Cameron McCormack  <heycam@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/failure-expected.txt

    r279895 r281472  
    55PASS XHR: file://example:1/ should throw
    66PASS sendBeacon(): file://example:1/ should throw
    7 FAIL Location's href: file://example:1/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     7PASS Location's href: file://example:1/ should throw
    88PASS window.open(): file://example:1/ should throw
    99PASS URL's constructor's base argument: file://example:test/ should throw
     
    1111PASS XHR: file://example:test/ should throw
    1212PASS sendBeacon(): file://example:test/ should throw
    13 FAIL Location's href: file://example:test/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     13PASS Location's href: file://example:test/ should throw
    1414PASS window.open(): file://example:test/ should throw
    1515PASS URL's constructor's base argument: file://example%/ should throw
     
    1717PASS XHR: file://example%/ should throw
    1818PASS sendBeacon(): file://example%/ should throw
    19 FAIL Location's href: file://example%/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     19PASS Location's href: file://example%/ should throw
    2020PASS window.open(): file://example%/ should throw
    2121PASS URL's constructor's base argument: file://[example]/ should throw
     
    2323PASS XHR: file://[example]/ should throw
    2424PASS sendBeacon(): file://[example]/ should throw
    25 FAIL Location's href: file://[example]/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     25PASS Location's href: file://[example]/ should throw
    2626PASS window.open(): file://[example]/ should throw
    2727PASS URL's constructor's base argument: http://user:pass@/ should throw
     
    2929PASS XHR: http://user:pass@/ should throw
    3030PASS sendBeacon(): http://user:pass@/ should throw
    31 FAIL Location's href: http://user:pass@/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     31PASS Location's href: http://user:pass@/ should throw
    3232PASS window.open(): http://user:pass@/ should throw
    3333PASS URL's constructor's base argument: http://foo:-80/ should throw
     
    3535PASS XHR: http://foo:-80/ should throw
    3636PASS sendBeacon(): http://foo:-80/ should throw
    37 FAIL Location's href: http://foo:-80/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     37PASS Location's href: http://foo:-80/ should throw
    3838PASS window.open(): http://foo:-80/ should throw
    3939PASS URL's constructor's base argument: http:/:@/www.example.com should throw
     
    4343PASS XHR: http://user@/www.example.com should throw
    4444PASS sendBeacon(): http://user@/www.example.com should throw
    45 FAIL Location's href: http://user@/www.example.com should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     45PASS Location's href: http://user@/www.example.com should throw
    4646PASS window.open(): http://user@/www.example.com should throw
    4747PASS URL's constructor's base argument: http:@/www.example.com should throw
     
    5353PASS XHR: http://@/www.example.com should throw
    5454PASS sendBeacon(): http://@/www.example.com should throw
    55 FAIL Location's href: http://@/www.example.com should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     55PASS Location's href: http://@/www.example.com should throw
    5656PASS window.open(): http://@/www.example.com should throw
    5757PASS URL's constructor's base argument: https:@/www.example.com should throw
     
    6565PASS XHR: http://a:b@/www.example.com should throw
    6666PASS sendBeacon(): http://a:b@/www.example.com should throw
    67 FAIL Location's href: http://a:b@/www.example.com should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     67PASS Location's href: http://a:b@/www.example.com should throw
    6868PASS window.open(): http://a:b@/www.example.com should throw
    6969PASS URL's constructor's base argument: http::@/www.example.com should throw
     
    7777PASS XHR: http://@:www.example.com should throw
    7878PASS sendBeacon(): http://@:www.example.com should throw
    79 FAIL Location's href: http://@:www.example.com should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     79PASS Location's href: http://@:www.example.com should throw
    8080PASS window.open(): http://@:www.example.com should throw
    8181PASS URL's constructor's base argument: https://� should throw
     
    8383PASS XHR: https://� should throw
    8484PASS sendBeacon(): https://� should throw
    85 FAIL Location's href: https://� should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     85PASS Location's href: https://� should throw
    8686PASS window.open(): https://� should throw
    8787PASS URL's constructor's base argument: https://%EF%BF%BD should throw
     
    8989PASS XHR: https://%EF%BF%BD should throw
    9090PASS sendBeacon(): https://%EF%BF%BD should throw
    91 FAIL Location's href: https://%EF%BF%BD should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     91PASS Location's href: https://%EF%BF%BD should throw
    9292PASS window.open(): https://%EF%BF%BD should throw
    9393PASS URL's constructor's base argument: http://a.b.c.xn--pokxncvks should throw
     
    9595PASS XHR: http://a.b.c.xn--pokxncvks should throw
    9696PASS sendBeacon(): http://a.b.c.xn--pokxncvks should throw
    97 FAIL Location's href: http://a.b.c.xn--pokxncvks should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     97PASS Location's href: http://a.b.c.xn--pokxncvks should throw
    9898PASS window.open(): http://a.b.c.xn--pokxncvks should throw
    9999PASS URL's constructor's base argument: http://10.0.0.xn--pokxncvks should throw
     
    101101PASS XHR: http://10.0.0.xn--pokxncvks should throw
    102102PASS sendBeacon(): http://10.0.0.xn--pokxncvks should throw
    103 FAIL Location's href: http://10.0.0.xn--pokxncvks should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     103PASS Location's href: http://10.0.0.xn--pokxncvks should throw
    104104PASS window.open(): http://10.0.0.xn--pokxncvks should throw
    105105PASS URL's constructor's base argument: https://x x:12 should throw
     
    107107PASS XHR: https://x x:12 should throw
    108108PASS sendBeacon(): https://x x:12 should throw
    109 FAIL Location's href: https://x x:12 should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     109PASS Location's href: https://x x:12 should throw
    110110PASS window.open(): https://x x:12 should throw
    111111PASS URL's constructor's base argument: http://[www.google.com]/ should throw
     
    113113PASS XHR: http://[www.google.com]/ should throw
    114114PASS sendBeacon(): http://[www.google.com]/ should throw
    115 FAIL Location's href: http://[www.google.com]/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     115PASS Location's href: http://[www.google.com]/ should throw
    116116PASS window.open(): http://[www.google.com]/ should throw
    117117PASS URL's constructor's base argument: sc://\0/ should throw
     
    119119PASS XHR: sc://\0/ should throw
    120120PASS sendBeacon(): sc://\0/ should throw
    121 FAIL Location's href: sc://\0/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     121PASS Location's href: sc://\0/ should throw
    122122PASS window.open(): sc://\0/ should throw
    123123PASS URL's constructor's base argument: sc:// / should throw
     
    125125PASS XHR: sc:// / should throw
    126126PASS sendBeacon(): sc:// / should throw
    127 FAIL Location's href: sc:// / should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     127PASS Location's href: sc:// / should throw
    128128PASS window.open(): sc:// / should throw
    129129PASS URL's constructor's base argument: sc://@/ should throw
     
    131131PASS XHR: sc://@/ should throw
    132132PASS sendBeacon(): sc://@/ should throw
    133 FAIL Location's href: sc://@/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     133PASS Location's href: sc://@/ should throw
    134134PASS window.open(): sc://@/ should throw
    135135PASS URL's constructor's base argument: sc://te@s:t@/ should throw
     
    137137PASS XHR: sc://te@s:t@/ should throw
    138138PASS sendBeacon(): sc://te@s:t@/ should throw
    139 FAIL Location's href: sc://te@s:t@/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     139PASS Location's href: sc://te@s:t@/ should throw
    140140PASS window.open(): sc://te@s:t@/ should throw
    141141PASS URL's constructor's base argument: sc://:/ should throw
     
    143143PASS XHR: sc://:/ should throw
    144144PASS sendBeacon(): sc://:/ should throw
    145 FAIL Location's href: sc://:/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     145PASS Location's href: sc://:/ should throw
    146146PASS window.open(): sc://:/ should throw
    147147PASS URL's constructor's base argument: sc://:12/ should throw
     
    149149PASS XHR: sc://:12/ should throw
    150150PASS sendBeacon(): sc://:12/ should throw
    151 FAIL Location's href: sc://:12/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     151PASS Location's href: sc://:12/ should throw
    152152PASS window.open(): sc://:12/ should throw
    153153PASS URL's constructor's base argument: sc://[/ should throw
     
    155155PASS XHR: sc://[/ should throw
    156156PASS sendBeacon(): sc://[/ should throw
    157 FAIL Location's href: sc://[/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     157PASS Location's href: sc://[/ should throw
    158158PASS window.open(): sc://[/ should throw
    159159PASS URL's constructor's base argument: sc://\/ should throw
     
    161161PASS XHR: sc://\/ should throw
    162162PASS sendBeacon(): sc://\/ should throw
    163 FAIL Location's href: sc://\/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     163PASS Location's href: sc://\/ should throw
    164164PASS window.open(): sc://\/ should throw
    165165PASS URL's constructor's base argument: sc://]/ should throw
     
    167167PASS XHR: sc://]/ should throw
    168168PASS sendBeacon(): sc://]/ should throw
    169 FAIL Location's href: sc://]/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     169PASS Location's href: sc://]/ should throw
    170170PASS window.open(): sc://]/ should throw
    171171PASS URL's constructor's base argument: http://a<b should throw
     
    173173PASS XHR: http://a<b should throw
    174174PASS sendBeacon(): http://a<b should throw
    175 FAIL Location's href: http://a<b should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     175PASS Location's href: http://a<b should throw
    176176PASS window.open(): http://a<b should throw
    177177PASS URL's constructor's base argument: http://a>b should throw
     
    179179PASS XHR: http://a>b should throw
    180180PASS sendBeacon(): http://a>b should throw
    181 FAIL Location's href: http://a>b should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     181PASS Location's href: http://a>b should throw
    182182PASS window.open(): http://a>b should throw
    183183PASS URL's constructor's base argument: http://a^b should throw
     
    185185PASS XHR: http://a^b should throw
    186186PASS sendBeacon(): http://a^b should throw
    187 FAIL Location's href: http://a^b should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     187PASS Location's href: http://a^b should throw
    188188PASS window.open(): http://a^b should throw
    189189PASS URL's constructor's base argument: non-special://a<b should throw
     
    191191PASS XHR: non-special://a<b should throw
    192192PASS sendBeacon(): non-special://a<b should throw
    193 FAIL Location's href: non-special://a<b should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     193PASS Location's href: non-special://a<b should throw
    194194PASS window.open(): non-special://a<b should throw
    195195PASS URL's constructor's base argument: non-special://a>b should throw
     
    197197PASS XHR: non-special://a>b should throw
    198198PASS sendBeacon(): non-special://a>b should throw
    199 FAIL Location's href: non-special://a>b should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     199PASS Location's href: non-special://a>b should throw
    200200PASS window.open(): non-special://a>b should throw
    201201PASS URL's constructor's base argument: non-special://a^b should throw
     
    203203PASS XHR: non-special://a^b should throw
    204204PASS sendBeacon(): non-special://a^b should throw
    205 FAIL Location's href: non-special://a^b should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     205PASS Location's href: non-special://a^b should throw
    206206PASS window.open(): non-special://a^b should throw
    207207PASS URL's constructor's base argument: foo://ho\0st/ should throw
     
    209209PASS XHR: foo://ho\0st/ should throw
    210210PASS sendBeacon(): foo://ho\0st/ should throw
    211 FAIL Location's href: foo://ho\0st/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     211PASS Location's href: foo://ho\0st/ should throw
    212212PASS window.open(): foo://ho\0st/ should throw
    213213PASS URL's constructor's base argument: foo://ho|st/ should throw
     
    215215PASS XHR: foo://ho|st/ should throw
    216216PASS sendBeacon(): foo://ho|st/ should throw
    217 FAIL Location's href: foo://ho|st/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     217PASS Location's href: foo://ho|st/ should throw
    218218PASS window.open(): foo://ho|st/ should throw
    219219PASS URL's constructor's base argument: http://ho%00st/ should throw
     
    221221PASS XHR: http://ho%00st/ should throw
    222222PASS sendBeacon(): http://ho%00st/ should throw
    223 FAIL Location's href: http://ho%00st/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     223PASS Location's href: http://ho%00st/ should throw
    224224PASS window.open(): http://ho%00st/ should throw
    225225PASS URL's constructor's base argument: http://ho%09st/ should throw
     
    227227PASS XHR: http://ho%09st/ should throw
    228228PASS sendBeacon(): http://ho%09st/ should throw
    229 FAIL Location's href: http://ho%09st/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     229PASS Location's href: http://ho%09st/ should throw
    230230PASS window.open(): http://ho%09st/ should throw
    231231PASS URL's constructor's base argument: http://ho%0Ast/ should throw
     
    233233PASS XHR: http://ho%0Ast/ should throw
    234234PASS sendBeacon(): http://ho%0Ast/ should throw
    235 FAIL Location's href: http://ho%0Ast/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     235PASS Location's href: http://ho%0Ast/ should throw
    236236PASS window.open(): http://ho%0Ast/ should throw
    237237PASS URL's constructor's base argument: http://ho%0Dst/ should throw
     
    239239PASS XHR: http://ho%0Dst/ should throw
    240240PASS sendBeacon(): http://ho%0Dst/ should throw
    241 FAIL Location's href: http://ho%0Dst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     241PASS Location's href: http://ho%0Dst/ should throw
    242242PASS window.open(): http://ho%0Dst/ should throw
    243243PASS URL's constructor's base argument: http://ho%20st/ should throw
     
    245245PASS XHR: http://ho%20st/ should throw
    246246PASS sendBeacon(): http://ho%20st/ should throw
    247 FAIL Location's href: http://ho%20st/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     247PASS Location's href: http://ho%20st/ should throw
    248248PASS window.open(): http://ho%20st/ should throw
    249249PASS URL's constructor's base argument: http://ho%23st/ should throw
     
    251251PASS XHR: http://ho%23st/ should throw
    252252PASS sendBeacon(): http://ho%23st/ should throw
    253 FAIL Location's href: http://ho%23st/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     253PASS Location's href: http://ho%23st/ should throw
    254254PASS window.open(): http://ho%23st/ should throw
    255255PASS URL's constructor's base argument: http://ho%2Fst/ should throw
     
    257257PASS XHR: http://ho%2Fst/ should throw
    258258PASS sendBeacon(): http://ho%2Fst/ should throw
    259 FAIL Location's href: http://ho%2Fst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     259PASS Location's href: http://ho%2Fst/ should throw
    260260PASS window.open(): http://ho%2Fst/ should throw
    261261PASS URL's constructor's base argument: http://ho%3Ast/ should throw
     
    263263PASS XHR: http://ho%3Ast/ should throw
    264264PASS sendBeacon(): http://ho%3Ast/ should throw
    265 FAIL Location's href: http://ho%3Ast/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     265PASS Location's href: http://ho%3Ast/ should throw
    266266PASS window.open(): http://ho%3Ast/ should throw
    267267PASS URL's constructor's base argument: http://ho%3Cst/ should throw
     
    269269PASS XHR: http://ho%3Cst/ should throw
    270270PASS sendBeacon(): http://ho%3Cst/ should throw
    271 FAIL Location's href: http://ho%3Cst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     271PASS Location's href: http://ho%3Cst/ should throw
    272272PASS window.open(): http://ho%3Cst/ should throw
    273273PASS URL's constructor's base argument: http://ho%3Est/ should throw
     
    275275PASS XHR: http://ho%3Est/ should throw
    276276PASS sendBeacon(): http://ho%3Est/ should throw
    277 FAIL Location's href: http://ho%3Est/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     277PASS Location's href: http://ho%3Est/ should throw
    278278PASS window.open(): http://ho%3Est/ should throw
    279279PASS URL's constructor's base argument: http://ho%3Fst/ should throw
     
    281281PASS XHR: http://ho%3Fst/ should throw
    282282PASS sendBeacon(): http://ho%3Fst/ should throw
    283 FAIL Location's href: http://ho%3Fst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     283PASS Location's href: http://ho%3Fst/ should throw
    284284PASS window.open(): http://ho%3Fst/ should throw
    285285PASS URL's constructor's base argument: http://ho%40st/ should throw
     
    287287PASS XHR: http://ho%40st/ should throw
    288288PASS sendBeacon(): http://ho%40st/ should throw
    289 FAIL Location's href: http://ho%40st/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     289PASS Location's href: http://ho%40st/ should throw
    290290PASS window.open(): http://ho%40st/ should throw
    291291PASS URL's constructor's base argument: http://ho%5Bst/ should throw
     
    293293PASS XHR: http://ho%5Bst/ should throw
    294294PASS sendBeacon(): http://ho%5Bst/ should throw
    295 FAIL Location's href: http://ho%5Bst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     295PASS Location's href: http://ho%5Bst/ should throw
    296296PASS window.open(): http://ho%5Bst/ should throw
    297297PASS URL's constructor's base argument: http://ho%5Cst/ should throw
     
    299299PASS XHR: http://ho%5Cst/ should throw
    300300PASS sendBeacon(): http://ho%5Cst/ should throw
    301 FAIL Location's href: http://ho%5Cst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     301PASS Location's href: http://ho%5Cst/ should throw
    302302PASS window.open(): http://ho%5Cst/ should throw
    303303PASS URL's constructor's base argument: http://ho%5Dst/ should throw
     
    305305PASS XHR: http://ho%5Dst/ should throw
    306306PASS sendBeacon(): http://ho%5Dst/ should throw
    307 FAIL Location's href: http://ho%5Dst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     307PASS Location's href: http://ho%5Dst/ should throw
    308308PASS window.open(): http://ho%5Dst/ should throw
    309309PASS URL's constructor's base argument: http://ho%7Cst/ should throw
     
    311311PASS XHR: http://ho%7Cst/ should throw
    312312PASS sendBeacon(): http://ho%7Cst/ should throw
    313 FAIL Location's href: http://ho%7Cst/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     313PASS Location's href: http://ho%7Cst/ should throw
    314314PASS window.open(): http://ho%7Cst/ should throw
    315315PASS URL's constructor's base argument: ftp://example.com%80/ should throw
     
    317317PASS XHR: ftp://example.com%80/ should throw
    318318PASS sendBeacon(): ftp://example.com%80/ should throw
    319 FAIL Location's href: ftp://example.com%80/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     319PASS Location's href: ftp://example.com%80/ should throw
    320320PASS window.open(): ftp://example.com%80/ should throw
    321321PASS URL's constructor's base argument: ftp://example.com%A0/ should throw
     
    323323PASS XHR: ftp://example.com%A0/ should throw
    324324PASS sendBeacon(): ftp://example.com%A0/ should throw
    325 FAIL Location's href: ftp://example.com%A0/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     325PASS Location's href: ftp://example.com%A0/ should throw
    326326PASS window.open(): ftp://example.com%A0/ should throw
    327327PASS URL's constructor's base argument: https://example.com%80/ should throw
     
    329329PASS XHR: https://example.com%80/ should throw
    330330PASS sendBeacon(): https://example.com%80/ should throw
    331 FAIL Location's href: https://example.com%80/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     331PASS Location's href: https://example.com%80/ should throw
    332332PASS window.open(): https://example.com%80/ should throw
    333333PASS URL's constructor's base argument: https://example.com%A0/ should throw
     
    335335PASS XHR: https://example.com%A0/ should throw
    336336PASS sendBeacon(): https://example.com%A0/ should throw
    337 FAIL Location's href: https://example.com%A0/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     337PASS Location's href: https://example.com%A0/ should throw
    338338PASS window.open(): https://example.com%A0/ should throw
    339339PASS URL's constructor's base argument: https://0x100000000/test should throw
     
    341341PASS XHR: https://0x100000000/test should throw
    342342PASS sendBeacon(): https://0x100000000/test should throw
    343 FAIL Location's href: https://0x100000000/test should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     343PASS Location's href: https://0x100000000/test should throw
    344344PASS window.open(): https://0x100000000/test should throw
    345345PASS URL's constructor's base argument: https://256.0.0.1/test should throw
     
    347347PASS XHR: https://256.0.0.1/test should throw
    348348PASS sendBeacon(): https://256.0.0.1/test should throw
    349 FAIL Location's href: https://256.0.0.1/test should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     349PASS Location's href: https://256.0.0.1/test should throw
    350350PASS window.open(): https://256.0.0.1/test should throw
    351351PASS URL's constructor's base argument: file://%43%3A should throw
     
    353353PASS XHR: file://%43%3A should throw
    354354PASS sendBeacon(): file://%43%3A should throw
    355 FAIL Location's href: file://%43%3A should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     355PASS Location's href: file://%43%3A should throw
    356356PASS window.open(): file://%43%3A should throw
    357357PASS URL's constructor's base argument: file://%43%7C should throw
     
    359359PASS XHR: file://%43%7C should throw
    360360PASS sendBeacon(): file://%43%7C should throw
    361 FAIL Location's href: file://%43%7C should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     361PASS Location's href: file://%43%7C should throw
    362362PASS window.open(): file://%43%7C should throw
    363363PASS URL's constructor's base argument: file://%43| should throw
     
    365365PASS XHR: file://%43| should throw
    366366PASS sendBeacon(): file://%43| should throw
    367 FAIL Location's href: file://%43| should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     367PASS Location's href: file://%43| should throw
    368368PASS window.open(): file://%43| should throw
    369369PASS URL's constructor's base argument: file://C%7C should throw
     
    371371PASS XHR: file://C%7C should throw
    372372PASS sendBeacon(): file://C%7C should throw
    373 FAIL Location's href: file://C%7C should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     373PASS Location's href: file://C%7C should throw
    374374PASS window.open(): file://C%7C should throw
    375375PASS URL's constructor's base argument: file://%43%7C/ should throw
     
    377377PASS XHR: file://%43%7C/ should throw
    378378PASS sendBeacon(): file://%43%7C/ should throw
    379 FAIL Location's href: file://%43%7C/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     379PASS Location's href: file://%43%7C/ should throw
    380380PASS window.open(): file://%43%7C/ should throw
    381381PASS URL's constructor's base argument: https://%43%7C/ should throw
     
    383383PASS XHR: https://%43%7C/ should throw
    384384PASS sendBeacon(): https://%43%7C/ should throw
    385 FAIL Location's href: https://%43%7C/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     385PASS Location's href: https://%43%7C/ should throw
    386386PASS window.open(): https://%43%7C/ should throw
    387387PASS URL's constructor's base argument: asdf://%43|/ should throw
     
    389389PASS XHR: asdf://%43|/ should throw
    390390PASS sendBeacon(): asdf://%43|/ should throw
    391 FAIL Location's href: asdf://%43|/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     391PASS Location's href: asdf://%43|/ should throw
    392392PASS window.open(): asdf://%43|/ should throw
    393393PASS URL's constructor's base argument: \\\.\Y: should throw
     
    399399PASS XHR: https://[0::0::0] should throw
    400400PASS sendBeacon(): https://[0::0::0] should throw
    401 FAIL Location's href: https://[0::0::0] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     401PASS Location's href: https://[0::0::0] should throw
    402402PASS window.open(): https://[0::0::0] should throw
    403403PASS URL's constructor's base argument: https://[0:.0] should throw
     
    405405PASS XHR: https://[0:.0] should throw
    406406PASS sendBeacon(): https://[0:.0] should throw
    407 FAIL Location's href: https://[0:.0] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     407PASS Location's href: https://[0:.0] should throw
    408408PASS window.open(): https://[0:.0] should throw
    409409PASS URL's constructor's base argument: https://[0:0:] should throw
     
    411411PASS XHR: https://[0:0:] should throw
    412412PASS sendBeacon(): https://[0:0:] should throw
    413 FAIL Location's href: https://[0:0:] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     413PASS Location's href: https://[0:0:] should throw
    414414PASS window.open(): https://[0:0:] should throw
    415415PASS URL's constructor's base argument: https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
     
    417417PASS XHR: https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
    418418PASS sendBeacon(): https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
    419 FAIL Location's href: https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     419PASS Location's href: https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
    420420PASS window.open(): https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
    421421PASS URL's constructor's base argument: https://[0:1.00.0.0.0] should throw
     
    423423PASS XHR: https://[0:1.00.0.0.0] should throw
    424424PASS sendBeacon(): https://[0:1.00.0.0.0] should throw
    425 FAIL Location's href: https://[0:1.00.0.0.0] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     425PASS Location's href: https://[0:1.00.0.0.0] should throw
    426426PASS window.open(): https://[0:1.00.0.0.0] should throw
    427427PASS URL's constructor's base argument: https://[0:1.290.0.0.0] should throw
     
    429429PASS XHR: https://[0:1.290.0.0.0] should throw
    430430PASS sendBeacon(): https://[0:1.290.0.0.0] should throw
    431 FAIL Location's href: https://[0:1.290.0.0.0] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     431PASS Location's href: https://[0:1.290.0.0.0] should throw
    432432PASS window.open(): https://[0:1.290.0.0.0] should throw
    433433PASS URL's constructor's base argument: https://[0:1.23.23] should throw
     
    435435PASS XHR: https://[0:1.23.23] should throw
    436436PASS sendBeacon(): https://[0:1.23.23] should throw
    437 FAIL Location's href: https://[0:1.23.23] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     437PASS Location's href: https://[0:1.23.23] should throw
    438438PASS window.open(): https://[0:1.23.23] should throw
    439439PASS URL's constructor's base argument: http://? should throw
     
    441441PASS XHR: http://? should throw
    442442PASS sendBeacon(): http://? should throw
    443 FAIL Location's href: http://? should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     443PASS Location's href: http://? should throw
    444444PASS window.open(): http://? should throw
    445445PASS URL's constructor's base argument: http://# should throw
     
    447447PASS XHR: http://# should throw
    448448PASS sendBeacon(): http://# should throw
    449 FAIL Location's href: http://# should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     449PASS Location's href: http://# should throw
    450450PASS window.open(): http://# should throw
    451451PASS URL's constructor's base argument: non-special://[:80/ should throw
     
    453453PASS XHR: non-special://[:80/ should throw
    454454PASS sendBeacon(): non-special://[:80/ should throw
    455 FAIL Location's href: non-special://[:80/ should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     455PASS Location's href: non-special://[:80/ should throw
    456456PASS window.open(): non-special://[:80/ should throw
    457457PASS URL's constructor's base argument: http://[::127.0.0.0.1] should throw
     
    459459PASS XHR: http://[::127.0.0.0.1] should throw
    460460PASS sendBeacon(): http://[::127.0.0.0.1] should throw
    461 FAIL Location's href: http://[::127.0.0.0.1] should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     461PASS Location's href: http://[::127.0.0.0.1] should throw
    462462PASS window.open(): http://[::127.0.0.0.1] should throw
    463463PASS URL's constructor's base argument: a should throw
     
    471471PASS XHR: file://­/p should throw
    472472PASS sendBeacon(): file://­/p should throw
    473 FAIL Location's href: file://­/p should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     473PASS Location's href: file://­/p should throw
    474474PASS window.open(): file://­/p should throw
    475475PASS URL's constructor's base argument: file://%C2%AD/p should throw
     
    477477PASS XHR: file://%C2%AD/p should throw
    478478PASS sendBeacon(): file://%C2%AD/p should throw
    479 FAIL Location's href: file://%C2%AD/p should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     479PASS Location's href: file://%C2%AD/p should throw
    480480PASS window.open(): file://%C2%AD/p should throw
    481481PASS URL's constructor's base argument: file://xn--/p should throw
     
    483483PASS XHR: file://xn--/p should throw
    484484PASS sendBeacon(): file://xn--/p should throw
    485 FAIL Location's href: file://xn--/p should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
     485PASS Location's href: file://xn--/p should throw
    486486PASS window.open(): file://xn--/p should throw
    487487
  • trunk/Source/WebCore/ChangeLog

    r281470 r281472  
     12021-08-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        Setting window.location.href to an invalid URL should throw a TypeError
     4        https://bugs.webkit.org/show_bug.cgi?id=229303
     5
     6        Reviewed by Chris Dumez.
     7
     8        This matches Firefox and the specification, and Chrome also throws an exception in this case.
     9
     10        * page/Location.cpp:
     11        (WebCore::Location::setLocation):
     12
    1132021-08-23  Cameron McCormack  <heycam@apple.com>
    214
  • trunk/Source/WebCore/page/Location.cpp

    r280826 r281472  
    278278    URL completedURL = firstFrame->document()->completeURL(urlString);
    279279
    280     // FIXME: The specification says to throw a SyntaxError if the URL is not valid.
    281     if (completedURL.isNull())
    282         return { };
     280    if (!completedURL.isValid())
     281        return Exception { TypeError, "Invalid URL"_s };
    283282
    284283    if (!incumbentWindow.document()->canNavigate(frame, completedURL))
Note: See TracChangeset for help on using the changeset viewer.