Changeset 280491 in webkit


Ignore:
Timestamp:
Jul 30, 2021 1:25:46 PM (12 months ago)
Author:
Chris Dumez
Message:

Document's fallback base URL should be deduced from its creator when URL is about:blank
https://bugs.webkit.org/show_bug.cgi?id=228624

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Rebaseline WPT test now that one more check is passing.

  • web-platform-tests/html/infrastructure/urls/terminology-0/document-base-url-expected.txt:

Source/WebCore:

Document's fallback base URL should be deduced from its creator when URL is about:blank:

Chrome and Firefox match the specification here.

Tests: http/tests/dom/iframe-no-src-local-origin-allow.html

http/tests/dom/iframe-no-src-set-location.html

  • dom/Document.cpp:

(WebCore::Document::updateBaseURL):

LayoutTests:

Update existing tests to reflect behavior change. I have verified that those tests were failing in Firefox & Chrome and
are now passing in those browsers.

  • http/tests/dom/iframe-no-src-local-origin-allow-expected.txt: Renamed from LayoutTests/fast/frames/iframe-no-src-local-origin-allow-expected.txt.
  • http/tests/dom/iframe-no-src-local-origin-allow.html: Renamed from LayoutTests/fast/frames/iframe-no-src-local-origin-allow.html.
  • http/tests/dom/iframe-no-src-set-location-expected.txt: Renamed from LayoutTests/fast/frames/iframe-no-src-set-location-expected.txt.
  • http/tests/dom/iframe-no-src-set-location.html: Renamed from LayoutTests/fast/frames/iframe-no-src-set-location.html.
  • http/tests/dom/resources/iframe-no-src-set-location-pass.html: Renamed from LayoutTests/fast/frames/resources/iframe-no-src-set-location-pass.html.
  • http/tests/security/aboutBlank/security-context-expected.txt:
  • http/tests/security/aboutBlank/security-context-grandchildren-expected.txt:
  • http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt:
  • http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt:
  • http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt:
  • http/tests/security/aboutBlank/security-context-window-open-expected.txt:
  • http/tests/security/aboutBlank/security-context-with-base-tag-expected.txt:
  • http/tests/security/aboutBlank/security-context-write-expected.txt:
  • http/tests/security/aboutBlank/security-context-writeln-expected.txt:
Location:
trunk
Files:
15 edited
5 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280482 r280491  
     12021-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Document's fallback base URL should be deduced from its creator when URL is about:blank
     4        https://bugs.webkit.org/show_bug.cgi?id=228624
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Update existing tests to reflect behavior change. I have verified that those tests were failing in Firefox & Chrome and
     9        are now passing in those browsers.
     10
     11        * http/tests/dom/iframe-no-src-local-origin-allow-expected.txt: Renamed from LayoutTests/fast/frames/iframe-no-src-local-origin-allow-expected.txt.
     12        * http/tests/dom/iframe-no-src-local-origin-allow.html: Renamed from LayoutTests/fast/frames/iframe-no-src-local-origin-allow.html.
     13        * http/tests/dom/iframe-no-src-set-location-expected.txt: Renamed from LayoutTests/fast/frames/iframe-no-src-set-location-expected.txt.
     14        * http/tests/dom/iframe-no-src-set-location.html: Renamed from LayoutTests/fast/frames/iframe-no-src-set-location.html.
     15        * http/tests/dom/resources/iframe-no-src-set-location-pass.html: Renamed from LayoutTests/fast/frames/resources/iframe-no-src-set-location-pass.html.
     16        * http/tests/security/aboutBlank/security-context-expected.txt:
     17        * http/tests/security/aboutBlank/security-context-grandchildren-expected.txt:
     18        * http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt:
     19        * http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt:
     20        * http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt:
     21        * http/tests/security/aboutBlank/security-context-window-open-expected.txt:
     22        * http/tests/security/aboutBlank/security-context-with-base-tag-expected.txt:
     23        * http/tests/security/aboutBlank/security-context-write-expected.txt:
     24        * http/tests/security/aboutBlank/security-context-writeln-expected.txt:
     25
    1262021-07-30  Chris Dumez  <cdumez@apple.com>
    227
  • trunk/LayoutTests/fast/dom/Window/open-invalid-url.html

    r235050 r280491  
    1212var a = window.open("about:blank","moonshine")
    1313function mountainGoat() {
    14         a.window.eval('setTimeout("try { window.open(\'/\'); alert(\'FAIL\'); } catch(ex) { alert(\'PASS\'); }; if (window.testRunner) testRunner.notifyDone()", 0)')
     14        a.window.eval('setTimeout("try { window.open(\'http://invalid:url\'); alert(\'FAIL\'); } catch(ex) { alert(\'PASS\'); }; if (window.testRunner) testRunner.notifyDone()", 0)')
    1515}
    1616setTimeout("mountainGoat()", 0)
  • trunk/LayoutTests/http/tests/dom/iframe-no-src-local-origin-allow-expected.txt

    r280490 r280491  
    44
    55
    6 PASS document.getElementById('theFrame').contentDocument.baseURI is 'about:blank'
     6PASS document.getElementById('theFrame').contentDocument.baseURI is "http://127.0.0.1:8000/dom/iframe-no-src-local-origin-allow.html"
    77PASS document.getElementById('theFrame').contentDocument.getElementById('innerFrame').contentDocument.body.innerHTML is 'PASS\n'
    88PASS successfullyParsed is true
  • trunk/LayoutTests/http/tests/dom/iframe-no-src-local-origin-allow.html

    r280490 r280491  
    11<html>
    22<head>
    3 <script src="../../resources/js-test-pre.js"></script>
     3<script src="/js-test-resources/js-test.js"></script>
    44<script>
    5 if (window.testRunner) {
    6     testRunner.dumpAsText();
    7     testRunner.waitUntilDone();
    8 }
    9 
    105var iframeHasLoadedFirstPage = false;
    116
    127function runTest()
    138{
    14     shouldBe("document.getElementById('theFrame').contentDocument.baseURI", "'about:blank'");
     9    shouldBeEqualToString("document.getElementById('theFrame').contentDocument.baseURI", "http://127.0.0.1:8000/dom/iframe-no-src-local-origin-allow.html");
    1510    var frameDoc = document.getElementById('theFrame').contentWindow.document;
    1611    var innerFrame = frameDoc.createElement("iframe");
     
    1914    innerFrame.onload = function() {
    2015        shouldBe("document.getElementById('theFrame').contentDocument.getElementById('innerFrame').contentDocument.body.innerHTML", "'PASS\\n'");
    21         isSuccessfullyParsed();
    22         if (window.testRunner)
    23             testRunner.notifyDone();
     16        finishJSTest();
    2417    }
    2518    frameDoc.body.appendChild(innerFrame);
     
    3124<script>
    3225description("This tests that an iframe with no src attribute uses the parent document's origin when resolving links inserted into the frame via JavaScript.");
     26jsTestIsAsync = true;
    3327</script>
    3428<iframe id="theFrame" onload="runTest()"></iframe>
  • trunk/LayoutTests/http/tests/dom/iframe-no-src-set-location-expected.txt

    r280490 r280491  
    44
    55
    6 PASS document.getElementById('theFrame').contentDocument.baseURI is 'about:blank'
     6PASS document.getElementById('theFrame').contentDocument.baseURI is "http://127.0.0.1:8000/dom/iframe-no-src-set-location.html"
    77PASS document.getElementById('theFrame').contentDocument.body.innerHTML is 'PASS\n'
    88PASS successfullyParsed is true
  • trunk/LayoutTests/http/tests/dom/iframe-no-src-set-location.html

    r280490 r280491  
    11<html>
    22<head>
    3 <script src="../../resources/js-test-pre.js"></script>
     3<script src="/js-test-resources/js-test.js"></script>
    44<script>
    5 if (window.testRunner) {
    6     testRunner.dumpAsText();
    7     testRunner.waitUntilDone();
    8 }
    9 
    105var iframeHasLoadedFirstPage = false;
    116
     
    1510        iframeHasLoadedFirstPage = true;
    1611
    17         shouldBe("document.getElementById('theFrame').contentDocument.baseURI", "'about:blank'");
     12        shouldBeEqualToString("document.getElementById('theFrame').contentDocument.baseURI", "http://127.0.0.1:8000/dom/iframe-no-src-set-location.html");
    1813        var iframe = document.getElementById('theFrame');
    1914        iframe.src = "javascript:document.location.replace('./resources/iframe-no-src-set-location-pass.html')";
     
    2116        shouldBe("document.getElementById('theFrame').contentDocument.body.innerHTML", "'PASS\\n'");
    2217
    23         isSuccessfullyParsed();
    24 
    25         if (window.testRunner) {
    26             testRunner.notifyDone();
    27         }
     18        finishJSTest();
    2819    }
    2920}
     
    3425<script>
    3526description("This tests that an iframe with no src attribute uses the parent document's URL as a base when resolving non-fully-qualified URLs set by JavaScript.");
     27jsTestIsAsync = true;
    3628</script>
    3729<iframe id="theFrame" onload="runTest()"></iframe>
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-expected.txt

    r34506 r280491  
    44* "about:blank"
    55document.URL = about:blank
    6 document.baseURI = about:blank
     6document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context.html
    77document.cookie = cookie=parent
    88* ""
    99document.URL = about:blank
    10 document.baseURI = about:blank
     10document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context.html
    1111document.cookie = cookie=parent
    1212--- After document.open() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-expected.txt

    r34506 r280491  
    33* "about:blank"
    44document.URL = about:blank
    5 document.baseURI = about:blank
     5document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    66document.cookie = cookie=resources; cookie=parent
    77* ""
    88document.URL = about:blank
    9 document.baseURI = about:blank
     9document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    1010document.cookie = cookie=resources; cookie=parent
    1111--- After document.open() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt

    r43604 r280491  
    44* "about:blank"
    55document.URL = about:blank
    6 document.baseURI = about:blank
     6document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    77document.cookie = cookie=resources; cookie=parent
    88* ""
    99document.URL = about:blank
    10 document.baseURI = about:blank
     10document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    1111document.cookie = cookie=resources; cookie=parent
    1212--- After document.open() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt

    r43604 r280491  
    44* "about:blank"
    55document.URL = about:blank
    6 document.baseURI = about:blank
     6document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    77document.cookie = cookie=resources; cookie=parent
    88* ""
    99document.URL = about:blank
    10 document.baseURI = about:blank
     10document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    1111document.cookie = cookie=resources; cookie=parent
    1212--- After document.open() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt

    r43604 r280491  
    44* "about:blank"
    55document.URL = about:blank
    6 document.baseURI = about:blank
     6document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    77document.cookie = cookie=resources; cookie=parent
    88* ""
    99document.URL = about:blank
    10 document.baseURI = about:blank
     10document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
    1111document.cookie = cookie=resources; cookie=parent
    1212--- After document.open() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-window-open-expected.txt

    r34506 r280491  
    22* "about:blank"
    33document.URL = about:blank
    4 document.baseURI = about:blank
     4document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-window-open.html
    55document.cookie = cookie=parent
    66* ""
    77document.URL = about:blank
    8 document.baseURI = about:blank
     8document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-window-open.html
    99document.cookie = cookie=parent
    1010--- After document.open() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-with-base-tag-expected.txt

    r34506 r280491  
    44* "about:blank"
    55document.URL = about:blank
    6 document.baseURI = about:blank
     6document.baseURI = http://set-by-base.example.com/
    77document.cookie = cookie=parent
    88* ""
    99document.URL = about:blank
    10 document.baseURI = about:blank
     10document.baseURI = http://set-by-base.example.com/
    1111document.cookie = cookie=parent
    1212--- After document.open() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-write-expected.txt

    r34506 r280491  
    44* "about:blank"
    55document.URL = about:blank
    6 document.baseURI = about:blank
     6document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-write.html
    77document.cookie = cookie=parent
    88* ""
    99document.URL = about:blank
    10 document.baseURI = about:blank
     10document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-write.html
    1111document.cookie = cookie=parent
    1212--- After document.write() ---
  • trunk/LayoutTests/http/tests/security/aboutBlank/security-context-writeln-expected.txt

    r34506 r280491  
    44* "about:blank"
    55document.URL = about:blank
    6 document.baseURI = about:blank
     6document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-writeln.html
    77document.cookie = cookie=parent
    88* ""
    99document.URL = about:blank
    10 document.baseURI = about:blank
     10document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-writeln.html
    1111document.cookie = cookie=parent
    1212--- After document.writeln() ---
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r280488 r280491  
     12021-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Document's fallback base URL should be deduced from its creator when URL is about:blank
     4        https://bugs.webkit.org/show_bug.cgi?id=228624
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Rebaseline WPT test now that one more check is passing.
     9
     10        * web-platform-tests/html/infrastructure/urls/terminology-0/document-base-url-expected.txt:
     11
    1122021-07-30  Jer Noble  <jer.noble@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/terminology-0/document-base-url-expected.txt

    r267646 r280491  
    22PASS The document base URL of a document containing one or more base elements with href attributes is the frozen base URL of the first base element in the document that has an href attribute, in tree order.
    33PASS The fallback base URL of a document containing no base element is the document's address.
    4 FAIL The fallback base URL of a document whose address is about:blank is the document base URL of the creator document. assert_equals: The document base URL should be the creator document's base URL. expected "http://localhost:8800/html/infrastructure/urls/terminology-0/document-base-url.html" but got "about:blank"
     4PASS The fallback base URL of a document whose address is about:blank is the document base URL of the creator document.
    55FAIL about:blank with a base element. assert_equals: img src should resolve correctly expected "http://localhost:8800/html/infrastructure/urls/terminology-0/sub/foo" but got "http://localhost:8800/html/infrastructure/urls/terminology-0/foo"
    66PASS The fallback base URL of an iframe srcdoc document is the document base URL of the document's browsing context's browsing context container's document.
  • trunk/Source/WebCore/ChangeLog

    r280488 r280491  
     12021-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Document's fallback base URL should be deduced from its creator when URL is about:blank
     4        https://bugs.webkit.org/show_bug.cgi?id=228624
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Document's fallback base URL should be deduced from its creator when URL is about:blank:
     9        - https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fallback-base-url
     10
     11        Chrome and Firefox match the specification here.
     12
     13        Tests: http/tests/dom/iframe-no-src-local-origin-allow.html
     14               http/tests/dom/iframe-no-src-set-location.html
     15
     16        * dom/Document.cpp:
     17        (WebCore::Document::updateBaseURL):
     18
    1192021-07-30  Jer Noble  <jer.noble@apple.com>
    220
  • trunk/Source/WebCore/dom/Document.cpp

    r280467 r280491  
    34073407void Document::updateBaseURL()
    34083408{
    3409     URL oldBaseURL = m_baseURL;
    34103409    // DOM 3 Core: When the Document supports the feature "HTML" [DOM Level 2 HTML], the base URI is computed using
    34113410    // first the value of the href attribute of the HTML BASE element if any, and the value of the documentURI attribute
     
    34203419        // and DOM 3 Core does not specify how it should be resolved.
    34213420        m_baseURL = URL({ }, documentURI());
     3421
     3422        if (m_baseURL == aboutBlankURL()) {
     3423            auto* creator = parentDocument();
     3424            if (!creator && frame() && frame()->loader().opener())
     3425                creator = frame()->loader().opener()->document();
     3426            if (creator)
     3427                m_baseURL = creator->baseURL();
     3428        }
    34223429    }
    34233430
Note: See TracChangeset for help on using the changeset viewer.