Changeset 235050 in webkit


Ignore:
Timestamp:
Aug 20, 2018 4:47:38 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Throw an exception if window.open() gets passed a URL that cannot be parsed
https://bugs.webkit.org/show_bug.cgi?id=171656

Patch by Rob Buis <rbuis@igalia.com> on 2018-08-20
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

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

Source/WebCore:

Throw a SyntaxError exception when an invalid url gets passed into window.open().

Tests: imported/w3c/web-platform-tests/url/failure.html

fast/dom/Window/open-invalid-url.html

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::createWindow):
(WebCore::DOMWindow::open):
(WebCore::DOMWindow::showModalDialog):

  • page/DOMWindow.h:
  • page/DOMWindow.idl:
  • testing/Internals.cpp:

(WebCore::Internals::openDummyInspectorFrontend):

LayoutTests:

  • fast/dom/Window/open-invalid-url-expected.txt:
  • fast/dom/Window/open-invalid-url.html:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r235026 r235050  
     12018-08-20  Rob Buis  <rbuis@igalia.com>
     2
     3        Throw an exception if window.open() gets passed a URL that cannot be parsed
     4        https://bugs.webkit.org/show_bug.cgi?id=171656
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/dom/Window/open-invalid-url-expected.txt:
     9        * fast/dom/Window/open-invalid-url.html:
     10
    1112018-08-20  Ms2ger  <Ms2ger@igalia.com>
    212
  • trunk/LayoutTests/fast/dom/Window/open-invalid-url-expected.txt

    r178527 r235050  
    1 CONSOLE MESSAGE: line 1: Unable to open a window with invalid URL '/'.
    2 
    31ALERT: PASS
    42
  • trunk/LayoutTests/fast/dom/Window/open-invalid-url.html

    r120792 r235050  
    1212var a = window.open("about:blank","moonshine")
    1313function mountainGoat() {
    14         a.window.eval('setTimeout("alert(window.open(\'/\') ? \'FAIL\' : \'PASS\'); if (window.testRunner) testRunner.notifyDone()", 0)')
     14        a.window.eval('setTimeout("try { window.open(\'/\'); alert(\'FAIL\'); } catch(ex) { alert(\'PASS\'); }; if (window.testRunner) testRunner.notifyDone()", 0)')
    1515}
    1616setTimeout("mountainGoat()", 0)
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r235025 r235050  
     12018-08-20  Rob Buis  <rbuis@igalia.com>
     2
     3        Throw an exception if window.open() gets passed a URL that cannot be parsed
     4        https://bugs.webkit.org/show_bug.cgi?id=171656
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/url/failure-expected.txt:
     9
    1102018-08-20  Rob Buis  <rbuis@igalia.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/failure-expected.txt

    r225085 r235050  
    11CONSOLE MESSAGE: line 38: Not allowed to load local resource: example:1
    2 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL ''.
    3 
    4 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL ''.
    5 
    6 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL ''.
    7 
    8 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://user:pass@/'.
    9 
    10 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://foo:-80/'.
    11 
    12 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://user@/www.example.com'.
    13 
    14 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://@/www.example.com'.
    15 
    16 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https:@/www.example.com'.
    17 
    18 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://a:b@/www.example.com'.
    19 
    20 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://@:www.example.com'.
    21 
    22 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://�'.
    23 
    24 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://%EF%BF%BD'.
    25 
    26 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://x x:12'.
    27 
    28 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://[www.google.com]/'.
    29 
    30 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://
    31 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc:// /'.
    32 
    33 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://@/'.
    34 
    35 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://te@s:t@/'.
    36 
    37 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://:/'.
    38 
    39 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://:12/'.
    40 
    41 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://[/'.
    42 
    43 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://\/'.
    44 
    45 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'sc://]/'.
    46 
    47 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'ftp://example.com%80/'.
    48 
    49 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'ftp://example.com%A0/'.
    50 
    51 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://example.com%80/'.
    52 
    53 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://example.com%A0/'.
    54 
    55 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://0x100000000/test'.
    56 
    57 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://256.0.0.1/test'.
    58 
    59 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://[0::0::0]'.
    60 
    61 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://[0:.0]'.
    62 
    63 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://[0:0:]'.
    64 
    65 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://[0:1:2:3:4:5:6:7.0.0.0.1]'.
    66 
    67 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://[0:1.00.0.0.0]'.
    68 
    69 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://[0:1.290.0.0.0]'.
    70 
    71 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'https://[0:1.23.23]'.
    72 
    73 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://?'.
    74 
    75 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://#'.
    76 
    77 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'non-special://[:80/'.
    78 
    79 CONSOLE MESSAGE: line 38: Unable to open a window with invalid URL 'http://[::127.0.0.0.1]'.
    80 
    812
    823PASS Loading data…
     
    9011PASS sendBeacon(): file://example:test/ should throw
    9112FAIL Location's href: file://example:test/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    92 FAIL window.open(): file://example:test/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     13PASS window.open(): file://example:test/ should throw
    9314PASS URL's href: file://example%/ should throw
    9415FAIL XHR: file://example%/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    9516PASS sendBeacon(): file://example%/ should throw
    9617FAIL Location's href: file://example%/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    97 FAIL window.open(): file://example%/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     18PASS window.open(): file://example%/ should throw
    9819PASS URL's href: file://[example]/ should throw
    9920FAIL XHR: file://[example]/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    10021PASS sendBeacon(): file://[example]/ should throw
    10122FAIL Location's href: file://[example]/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    102 FAIL window.open(): file://[example]/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     23PASS window.open(): file://[example]/ should throw
    10324PASS URL's href: http://user:pass@/ should throw
    10425FAIL XHR: http://user:pass@/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    10526PASS sendBeacon(): http://user:pass@/ should throw
    10627FAIL Location's href: http://user:pass@/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    107 FAIL window.open(): http://user:pass@/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     28PASS window.open(): http://user:pass@/ should throw
    10829PASS URL's href: http://foo:-80/ should throw
    10930FAIL XHR: http://foo:-80/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    11031PASS sendBeacon(): http://foo:-80/ should throw
    11132FAIL Location's href: http://foo:-80/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    112 FAIL window.open(): http://foo:-80/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     33PASS window.open(): http://foo:-80/ should throw
    11334PASS URL's href: http:/:@/www.example.com should throw
    11435FAIL XHR: http:/:@/www.example.com should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
     
    12041PASS sendBeacon(): http://user@/www.example.com should throw
    12142FAIL Location's href: http://user@/www.example.com should throw assert_throws: function "() => self[0].location = test.input" did not throw
    122 FAIL window.open(): http://user@/www.example.com should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     43PASS window.open(): http://user@/www.example.com should throw
    12344PASS URL's href: http:@/www.example.com should throw
    12445FAIL XHR: http:@/www.example.com should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
     
    13556PASS sendBeacon(): http://@/www.example.com should throw
    13657FAIL Location's href: http://@/www.example.com should throw assert_throws: function "() => self[0].location = test.input" did not throw
    137 FAIL window.open(): http://@/www.example.com should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     58PASS window.open(): http://@/www.example.com should throw
    13859PASS URL's href: https:@/www.example.com should throw
    13960FAIL XHR: https:@/www.example.com should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    14061PASS sendBeacon(): https:@/www.example.com should throw
    14162FAIL Location's href: https:@/www.example.com should throw assert_throws: function "() => self[0].location = test.input" did not throw
    142 FAIL window.open(): https:@/www.example.com should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     63PASS window.open(): https:@/www.example.com should throw
    14364PASS URL's href: http:a:b@/www.example.com should throw
    14465FAIL XHR: http:a:b@/www.example.com should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
     
    15576PASS sendBeacon(): http://a:b@/www.example.com should throw
    15677FAIL Location's href: http://a:b@/www.example.com should throw assert_throws: function "() => self[0].location = test.input" did not throw
    157 FAIL window.open(): http://a:b@/www.example.com should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     78PASS window.open(): http://a:b@/www.example.com should throw
    15879PASS URL's href: http::@/www.example.com should throw
    15980FAIL XHR: http::@/www.example.com should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
     
    17596PASS sendBeacon(): http://@:www.example.com should throw
    17697FAIL Location's href: http://@:www.example.com should throw assert_throws: function "() => self[0].location = test.input" did not throw
    177 FAIL window.open(): http://@:www.example.com should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     98PASS window.open(): http://@:www.example.com should throw
    17899PASS URL's href: https://� should throw
    179100FAIL XHR: https://� should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    180101PASS sendBeacon(): https://� should throw
    181102FAIL Location's href: https://� should throw assert_throws: function "() => self[0].location = test.input" did not throw
    182 FAIL window.open(): https://� should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     103PASS window.open(): https://� should throw
    183104PASS URL's href: https://%EF%BF%BD should throw
    184105FAIL XHR: https://%EF%BF%BD should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    185106PASS sendBeacon(): https://%EF%BF%BD should throw
    186107FAIL Location's href: https://%EF%BF%BD should throw assert_throws: function "() => self[0].location = test.input" did not throw
    187 FAIL window.open(): https://%EF%BF%BD should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     108PASS window.open(): https://%EF%BF%BD should throw
    188109PASS URL's href: https://x x:12 should throw
    189110FAIL XHR: https://x x:12 should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    190111PASS sendBeacon(): https://x x:12 should throw
    191112FAIL Location's href: https://x x:12 should throw assert_throws: function "() => self[0].location = test.input" did not throw
    192 FAIL window.open(): https://x x:12 should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     113PASS window.open(): https://x x:12 should throw
    193114PASS URL's href: http://[www.google.com]/ should throw
    194115FAIL XHR: http://[www.google.com]/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    195116PASS sendBeacon(): http://[www.google.com]/ should throw
    196117FAIL Location's href: http://[www.google.com]/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    197 FAIL window.open(): http://[www.google.com]/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     118PASS window.open(): http://[www.google.com]/ should throw
    198119PASS URL's href: sc://\0/ should throw
    199120FAIL XHR: sc://\0/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    200121PASS sendBeacon(): sc://\0/ should throw
    201122FAIL Location's href: sc://\0/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    202 FAIL window.open(): sc://\0/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     123PASS window.open(): sc://\0/ should throw
    203124PASS URL's href: sc:// / should throw
    204125FAIL XHR: sc:// / should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    205126PASS sendBeacon(): sc:// / should throw
    206127FAIL Location's href: sc:// / should throw assert_throws: function "() => self[0].location = test.input" did not throw
    207 FAIL window.open(): sc:// / should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     128PASS window.open(): sc:// / should throw
    208129PASS URL's href: sc://@/ should throw
    209130FAIL XHR: sc://@/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    210131PASS sendBeacon(): sc://@/ should throw
    211132FAIL Location's href: sc://@/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    212 FAIL window.open(): sc://@/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     133PASS window.open(): sc://@/ should throw
    213134PASS URL's href: sc://te@s:t@/ should throw
    214135FAIL XHR: sc://te@s:t@/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    215136PASS sendBeacon(): sc://te@s:t@/ should throw
    216137FAIL Location's href: sc://te@s:t@/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    217 FAIL window.open(): sc://te@s:t@/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     138PASS window.open(): sc://te@s:t@/ should throw
    218139PASS URL's href: sc://:/ should throw
    219140FAIL XHR: sc://:/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    220141PASS sendBeacon(): sc://:/ should throw
    221142FAIL Location's href: sc://:/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    222 FAIL window.open(): sc://:/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     143PASS window.open(): sc://:/ should throw
    223144PASS URL's href: sc://:12/ should throw
    224145FAIL XHR: sc://:12/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    225146PASS sendBeacon(): sc://:12/ should throw
    226147FAIL Location's href: sc://:12/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    227 FAIL window.open(): sc://:12/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     148PASS window.open(): sc://:12/ should throw
    228149PASS URL's href: sc://[/ should throw
    229150FAIL XHR: sc://[/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    230151PASS sendBeacon(): sc://[/ should throw
    231152FAIL Location's href: sc://[/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    232 FAIL window.open(): sc://[/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     153PASS window.open(): sc://[/ should throw
    233154PASS URL's href: sc://\/ should throw
    234155FAIL XHR: sc://\/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    235156PASS sendBeacon(): sc://\/ should throw
    236157FAIL Location's href: sc://\/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    237 FAIL window.open(): sc://\/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     158PASS window.open(): sc://\/ should throw
    238159PASS URL's href: sc://]/ should throw
    239160FAIL XHR: sc://]/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    240161PASS sendBeacon(): sc://]/ should throw
    241162FAIL Location's href: sc://]/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    242 FAIL window.open(): sc://]/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     163PASS window.open(): sc://]/ should throw
    243164PASS URL's href: ftp://example.com%80/ should throw
    244165FAIL XHR: ftp://example.com%80/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    245166PASS sendBeacon(): ftp://example.com%80/ should throw
    246167FAIL Location's href: ftp://example.com%80/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    247 FAIL window.open(): ftp://example.com%80/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     168PASS window.open(): ftp://example.com%80/ should throw
    248169PASS URL's href: ftp://example.com%A0/ should throw
    249170FAIL XHR: ftp://example.com%A0/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    250171PASS sendBeacon(): ftp://example.com%A0/ should throw
    251172FAIL Location's href: ftp://example.com%A0/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    252 FAIL window.open(): ftp://example.com%A0/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     173PASS window.open(): ftp://example.com%A0/ should throw
    253174PASS URL's href: https://example.com%80/ should throw
    254175FAIL XHR: https://example.com%80/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    255176PASS sendBeacon(): https://example.com%80/ should throw
    256177FAIL Location's href: https://example.com%80/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    257 FAIL window.open(): https://example.com%80/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     178PASS window.open(): https://example.com%80/ should throw
    258179PASS URL's href: https://example.com%A0/ should throw
    259180FAIL XHR: https://example.com%A0/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    260181PASS sendBeacon(): https://example.com%A0/ should throw
    261182FAIL Location's href: https://example.com%A0/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    262 FAIL window.open(): https://example.com%A0/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     183PASS window.open(): https://example.com%A0/ should throw
    263184PASS URL's href: https://0x100000000/test should throw
    264185FAIL XHR: https://0x100000000/test should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    265186PASS sendBeacon(): https://0x100000000/test should throw
    266187FAIL Location's href: https://0x100000000/test should throw assert_throws: function "() => self[0].location = test.input" did not throw
    267 FAIL window.open(): https://0x100000000/test should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     188PASS window.open(): https://0x100000000/test should throw
    268189PASS URL's href: https://256.0.0.1/test should throw
    269190FAIL XHR: https://256.0.0.1/test should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    270191PASS sendBeacon(): https://256.0.0.1/test should throw
    271192FAIL Location's href: https://256.0.0.1/test should throw assert_throws: function "() => self[0].location = test.input" did not throw
    272 FAIL window.open(): https://256.0.0.1/test should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     193PASS window.open(): https://256.0.0.1/test should throw
    273194PASS URL's href: https://[0::0::0] should throw
    274195FAIL XHR: https://[0::0::0] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    275196PASS sendBeacon(): https://[0::0::0] should throw
    276197FAIL Location's href: https://[0::0::0] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    277 FAIL window.open(): https://[0::0::0] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     198PASS window.open(): https://[0::0::0] should throw
    278199PASS URL's href: https://[0:.0] should throw
    279200FAIL XHR: https://[0:.0] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    280201PASS sendBeacon(): https://[0:.0] should throw
    281202FAIL Location's href: https://[0:.0] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    282 FAIL window.open(): https://[0:.0] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     203PASS window.open(): https://[0:.0] should throw
    283204PASS URL's href: https://[0:0:] should throw
    284205FAIL XHR: https://[0:0:] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    285206PASS sendBeacon(): https://[0:0:] should throw
    286207FAIL Location's href: https://[0:0:] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    287 FAIL window.open(): https://[0:0:] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     208PASS window.open(): https://[0:0:] should throw
    288209PASS URL's href: https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
    289210FAIL XHR: https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    290211PASS sendBeacon(): https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
    291212FAIL Location's href: https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    292 FAIL window.open(): https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     213PASS window.open(): https://[0:1:2:3:4:5:6:7.0.0.0.1] should throw
    293214PASS URL's href: https://[0:1.00.0.0.0] should throw
    294215FAIL XHR: https://[0:1.00.0.0.0] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    295216PASS sendBeacon(): https://[0:1.00.0.0.0] should throw
    296217FAIL Location's href: https://[0:1.00.0.0.0] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    297 FAIL window.open(): https://[0:1.00.0.0.0] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     218PASS window.open(): https://[0:1.00.0.0.0] should throw
    298219PASS URL's href: https://[0:1.290.0.0.0] should throw
    299220FAIL XHR: https://[0:1.290.0.0.0] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    300221PASS sendBeacon(): https://[0:1.290.0.0.0] should throw
    301222FAIL Location's href: https://[0:1.290.0.0.0] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    302 FAIL window.open(): https://[0:1.290.0.0.0] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     223PASS window.open(): https://[0:1.290.0.0.0] should throw
    303224PASS URL's href: https://[0:1.23.23] should throw
    304225FAIL XHR: https://[0:1.23.23] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    305226PASS sendBeacon(): https://[0:1.23.23] should throw
    306227FAIL Location's href: https://[0:1.23.23] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    307 FAIL window.open(): https://[0:1.23.23] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     228PASS window.open(): https://[0:1.23.23] should throw
    308229PASS URL's href: http://? should throw
    309230FAIL XHR: http://? should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    310231PASS sendBeacon(): http://? should throw
    311232FAIL Location's href: http://? should throw assert_throws: function "() => self[0].location = test.input" did not throw
    312 FAIL window.open(): http://? should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     233PASS window.open(): http://? should throw
    313234PASS URL's href: http://# should throw
    314235FAIL XHR: http://# should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    315236PASS sendBeacon(): http://# should throw
    316237FAIL Location's href: http://# should throw assert_throws: function "() => self[0].location = test.input" did not throw
    317 FAIL window.open(): http://# should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     238PASS window.open(): http://# should throw
    318239PASS URL's href: non-special://[:80/ should throw
    319240FAIL XHR: non-special://[:80/ should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    320241PASS sendBeacon(): non-special://[:80/ should throw
    321242FAIL Location's href: non-special://[:80/ should throw assert_throws: function "() => self[0].location = test.input" did not throw
    322 FAIL window.open(): non-special://[:80/ should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     243PASS window.open(): non-special://[:80/ should throw
    323244PASS URL's href: http://[::127.0.0.0.1] should throw
    324245FAIL XHR: http://[::127.0.0.0.1] should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
    325246PASS sendBeacon(): http://[::127.0.0.0.1] should throw
    326247FAIL Location's href: http://[::127.0.0.0.1] should throw assert_throws: function "() => self[0].location = test.input" did not throw
    327 FAIL window.open(): http://[::127.0.0.0.1] should throw assert_throws: function "() => self.open(test.input).close()" threw object "TypeError: null is not an object (evaluating 'self.open(test.input).close')" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
     248PASS window.open(): http://[::127.0.0.0.1] should throw
    328249
  • trunk/Source/WebCore/ChangeLog

    r235026 r235050  
     12018-08-20  Rob Buis  <rbuis@igalia.com>
     2
     3        Throw an exception if window.open() gets passed a URL that cannot be parsed
     4        https://bugs.webkit.org/show_bug.cgi?id=171656
     5
     6        Reviewed by Darin Adler.
     7
     8        Throw a SyntaxError exception when an invalid url gets passed into window.open().
     9
     10        Tests: imported/w3c/web-platform-tests/url/failure.html
     11               fast/dom/Window/open-invalid-url.html
     12
     13        * page/DOMWindow.cpp:
     14        (WebCore::DOMWindow::createWindow):
     15        (WebCore::DOMWindow::open):
     16        (WebCore::DOMWindow::showModalDialog):
     17        * page/DOMWindow.h:
     18        * page/DOMWindow.idl:
     19        * testing/Internals.cpp:
     20        (WebCore::Internals::openDummyInspectorFrontend):
     21
    1222018-08-20  Ms2ger  <Ms2ger@igalia.com>
    223
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r234995 r235050  
    22362236}
    22372237
    2238 RefPtr<Frame> DOMWindow::createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures& windowFeatures, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, const WTF::Function<void (DOMWindow&)>& prepareDialogFunction)
     2238ExceptionOr<RefPtr<Frame>> DOMWindow::createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures& windowFeatures, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction)
    22392239{
    22402240    Frame* activeFrame = activeWindow.frame();
    22412241    if (!activeFrame)
    2242         return nullptr;
     2242        return RefPtr<Frame> { nullptr };
    22432243
    22442244    Document* activeDocument = activeWindow.document();
    22452245    if (!activeDocument)
    2246         return nullptr;
     2246        return RefPtr<Frame> { nullptr };
    22472247
    22482248    URL completedURL = urlString.isEmpty() ? URL(ParsedURLString, emptyString()) : firstFrame.document()->completeURL(urlString);
    2249     if (!completedURL.isEmpty() && !completedURL.isValid()) {
    2250         // Don't expose client code to invalid URLs.
    2251         activeWindow.printErrorMessage("Unable to open a window with invalid URL '" + completedURL.string() + "'.\n");
    2252         return nullptr;
    2253     }
     2249    if (!completedURL.isEmpty() && !completedURL.isValid())
     2250        return Exception { SyntaxError };
    22542251
    22552252    // For whatever reason, Firefox uses the first frame to determine the outgoingReferrer. We replicate that behavior here.
     
    22662263    RefPtr<Frame> newFrame = WebCore::createWindow(*activeFrame, openerFrame, WTFMove(frameLoadRequest), windowFeatures, created);
    22672264    if (!newFrame)
    2268         return nullptr;
     2265        return RefPtr<Frame> { nullptr };
    22692266
    22702267    if (!windowFeatures.noopener)
     
    22732270
    22742271    if (newFrame->document()->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
    2275         return windowFeatures.noopener ? nullptr : newFrame;
     2272        return windowFeatures.noopener ? RefPtr<Frame> { nullptr } : newFrame;
    22762273
    22772274    if (prepareDialogFunction)
     
    22992296    // Navigating the new frame could result in it being detached from its page by a navigation policy delegate.
    23002297    if (!newFrame->page())
    2301         return nullptr;
    2302 
    2303     return windowFeatures.noopener ? nullptr : newFrame;
    2304 }
    2305 
    2306 RefPtr<WindowProxy> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString)
    2307 {
    2308     if (!isCurrentlyDisplayedInFrame())
    2309         return nullptr;
     2298        return RefPtr<Frame> { nullptr };
     2299
     2300    return windowFeatures.noopener ? RefPtr<Frame> { nullptr } : newFrame;
     2301}
     2302
     2303ExceptionOr<RefPtr<WindowProxy>> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString)
     2304{
     2305    if (!isCurrentlyDisplayedInFrame())
     2306        return RefPtr<WindowProxy> { nullptr };
    23102307
    23112308    auto* activeDocument = activeWindow.document();
    23122309    if (!activeDocument)
    2313         return nullptr;
     2310        return RefPtr<WindowProxy> { nullptr };
    23142311
    23152312    auto* firstFrame = firstWindow.frame();
    23162313    if (!firstFrame)
    2317         return nullptr;
     2314        return RefPtr<WindowProxy> { nullptr };
    23182315
    23192316#if ENABLE(CONTENT_EXTENSIONS)
     
    23252322        for (auto& action : firstFrame->page()->userContentProvider().actionsForResourceLoad(resourceLoadInfo, *firstFrame->mainFrame().document()->loader()).first) {
    23262323            if (action.type() == ContentExtensions::ActionType::BlockLoad)
    2327                 return nullptr;
     2324                return RefPtr<WindowProxy> { nullptr };
    23282325        }
    23292326    }
     
    23342331        // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.
    23352332        if (frameName.isEmpty() || !m_frame->loader().findFrameForNavigation(frameName, activeDocument))
    2336             return nullptr;
     2333            return RefPtr<WindowProxy> { nullptr };
    23372334    }
    23382335
     
    23502347    if (targetFrame) {
    23512348        if (!activeDocument->canNavigate(targetFrame))
    2352             return nullptr;
     2349            return RefPtr<WindowProxy> { nullptr };
    23532350
    23542351        URL completedURL = firstFrame->document()->completeURL(urlString);
     
    23682365    }
    23692366
    2370     auto newFrame = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *m_frame);
    2371     return newFrame ? &newFrame->windowProxy() : nullptr;
     2367    auto newFrameOrException = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *m_frame);
     2368    if (newFrameOrException.hasException())
     2369        return newFrameOrException.releaseException();
     2370
     2371    auto newFrame = newFrameOrException.releaseReturnValue();
     2372    return newFrame ? &newFrame->windowProxy() : RefPtr<WindowProxy> { nullptr };
    23722373}
    23732374
     
    23942395        return;
    23952396
    2396     RefPtr<Frame> dialogFrame = createWindow(urlString, emptyAtom(), parseDialogFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view())), activeWindow, *firstFrame, *m_frame, prepareDialogFunction);
     2397    auto dialogFrameOrException = createWindow(urlString, emptyAtom(), parseDialogFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view())), activeWindow, *firstFrame, *m_frame, prepareDialogFunction);
     2398    if (dialogFrameOrException.hasException())
     2399        return;
     2400    RefPtr<Frame> dialogFrame = dialogFrameOrException.releaseReturnValue();
    23972401    if (!dialogFrame)
    23982402        return;
  • trunk/Source/WebCore/page/DOMWindow.h

    r232613 r235050  
    160160    void stop();
    161161
    162     WEBCORE_EXPORT RefPtr<WindowProxy> open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString);
     162    WEBCORE_EXPORT ExceptionOr<RefPtr<WindowProxy>> open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString);
    163163
    164164    void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction);
     
    351351    void willDetachPage() final;
    352352
    353     static RefPtr<Frame> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction = nullptr);
     353    static ExceptionOr<RefPtr<Frame>> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction = nullptr);
    354354    bool isInsecureScriptAccess(DOMWindow& activeWindow, const String& urlString);
    355355
  • trunk/Source/WebCore/page/DOMWindow.idl

    r234588 r235050  
    7777    [Replaceable, DoNotCheckSecurityIf=CrossOriginWindowPolicyAllow] readonly attribute WindowProxy? parent;
    7878    [CheckSecurityForNode] readonly attribute Element? frameElement;
    79     [CallWith=ActiveWindow&FirstWindow] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");
     79    [CallWith=ActiveWindow&FirstWindow, MayThrowException] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");
    8080
    8181    // The user agent.
  • trunk/Source/WebCore/testing/Internals.cpp

    r235014 r235050  
    23322332    auto* inspectedPage = contextDocument()->frame()->page();
    23332333    auto* window = inspectedPage->mainFrame().document()->domWindow();
    2334     auto frontendWindowProxy = window->open(*window, *window, url, "", "");
     2334    auto frontendWindowProxy = window->open(*window, *window, url, "", "").releaseReturnValue();
    23352335    m_inspectorFrontend = std::make_unique<InspectorStubFrontend>(*inspectedPage, downcast<DOMWindow>(frontendWindowProxy->window()));
    23362336    return frontendWindowProxy;
Note: See TracChangeset for help on using the changeset viewer.