Changeset 229369 in webkit


Ignore:
Timestamp:
Mar 7, 2018 10:38:51 AM (6 years ago)
Author:
Chris Dumez
Message:

http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates
https://bugs.webkit.org/show_bug.cgi?id=183394

Reviewed by Alex Christensen.

http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates.
The issue is that the test calls window.open() with a cross-origin URL and then right away tries to access
newWindow.document, expecting it to throw. However, there is no guarantee that the cross origin URL has
started loading at this point. In particular, when the navigation policy decision is made asynchronously,
the URL is initially "about:blank" and it is OK to access the newWindow's document at this point.

We would normally rely on the window's load event before doing the check. However, this would not work
here since the window is cross origin. As a result, I am using a setInterval() in order to wait for the
cross-origin URL to load and for newWindow.document to start throwing.

  • http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates-expected.txt: Added.
  • http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates.html: Added.
  • http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt:
  • http/tests/dom/window-open-about-webkit-org-and-access-document.html:
Location:
trunk/LayoutTests
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r229363 r229369  
     12018-03-07  Chris Dumez  <cdumez@apple.com>
     2
     3        http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates
     4        https://bugs.webkit.org/show_bug.cgi?id=183394
     5
     6        Reviewed by Alex Christensen.
     7
     8        http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates.
     9        The issue is that the test calls window.open() with a cross-origin URL and then right away tries to access
     10        newWindow.document, expecting it to throw. However, there is no guarantee that the cross origin URL has
     11        started loading at this point. In particular, when the navigation policy decision is made asynchronously,
     12        the URL is initially "about:blank" and it is OK to access the newWindow's document at this point.
     13
     14        We would normally rely on the window's load event before doing the check. However, this would not work
     15        here since the window is cross origin. As a result, I am using a setInterval() in order to wait for the
     16        cross-origin URL to load and for newWindow.document to start throwing.
     17
     18        * http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates-expected.txt: Added.
     19        * http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates.html: Added.
     20        * http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt:
     21        * http/tests/dom/window-open-about-webkit-org-and-access-document.html:
     22
    1232018-03-07  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt

    r219663 r229369  
    1 CONSOLE MESSAGE: line 29: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "null".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "about". Protocols must match.
     1Tests opening a new about://webkit.org window and accessing its document
    22
    3 PASS newWindow.document threw exception SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "null".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "about". Protocols must match.
    4 .
     3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    54
     5
     6PASS e.name is "SecurityError"
     7PASS successfullyParsed is true
     8
     9TEST COMPLETE
     10
  • trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document.html

    r205136 r229369  
    11<!DOCTYPE html>
    2 <html lang="en">
    3 <head>
    4     <title>Tests opening a new about://webkit.org window and accessing its document</title>
    5     <script src="../resources/js-test-pre.js"></script>
     2<html>
     3<body>
     4    <script src="/js-test-resources/js-test.js"></script>
    65    <script>
     6        description("Tests opening a new about://webkit.org window and accessing its document");
     7        jsTestIsAsync = true;
     8
    79        var newWindow;
    810
    911        if (window.testRunner) {
    1012            testRunner.setCanOpenWindows();
    11             testRunner.waitUntilDone();
    1213            testRunner.setPopupBlockingEnabled(false);
    1314        }
    1415
    15         function checkNewWindowDocumentIsUndefined () {
    16             shouldThrowErrorName("newWindow.document", "SecurityError");
    17             if (window.testRunner)
    18                 testRunner.notifyDone();
     16        function finish()
     17        {
     18            clearInterval(handle);
     19            finishJSTest();
    1920        }
    2021
    21         function run() {
    22             newWindow = window.open("about://webkit.org");
     22        function checkCannotAccessDocument()
     23        {
    2324            try {
    24                 newWindow.document.write("<scri" + "pt>console.log('Injected script running.')</sc" + "ript>");
    25                 testFailed("Was able to write to the new window's document.");
    26                 if (window.testRunner)
    27                     testRunner.notifyDone();
    28             } catch (e) {
    29                 console.log(e);
    30                 setTimeout(checkNewWindowDocumentIsUndefined, 500);
     25                newWindow.document;
     26                if (newWindow.document.URL != "about:blank") {
     27                    testFailed("Managed to access the document at URL " + newWindow.document.URL);
     28                    finish();
     29                }
     30            } catch (_e) {
     31                e = _e;
     32                shouldBeEqualToString("e.name", "SecurityError");
     33                finish();
    3134            }
    3235        }
     36
     37        onload = function () {
     38            newWindow = window.open("about://webkit.org");
     39            handle = setInterval(checkCannotAccessDocument, 5);
     40
     41        }
    3342    </script>
    34 </head>
    35 <body onload="run()">
    36 <div id="console"></div>
    3743</body>
    3844</html>
Note: See TracChangeset for help on using the changeset viewer.