Changeset 284934 in webkit


Ignore:
Timestamp:
Oct 27, 2021 12:05:46 PM (9 months ago)
Author:
Chris Dumez
Message:

JavaScript URL result should be treated as UTF-8 bytes
https://bugs.webkit.org/show_bug.cgi?id=232380

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline WPT test now that more checks are passing. The remaining failures are due to the fact that we ignore the JavaScript URL result
when the URL is set as href on an anchor (as opposed to the src of an iframe). This will be addressed separately.

  • web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling-dynamic-expected.txt:

Source/WebCore:

JavaScript URL result should be treated as UTF-8 bytes:

No new tests, rebaselined existing test.

  • loader/DocumentWriter.cpp:

(WebCore::DocumentWriter::replaceDocumentWithResultOfExecutingJavascriptURL):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r284901 r284934  
     12021-10-27  Chris Dumez  <cdumez@apple.com>
     2
     3        JavaScript URL result should be treated as UTF-8 bytes
     4        https://bugs.webkit.org/show_bug.cgi?id=232380
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline WPT test now that more checks are passing. The remaining failures are due to the fact that we ignore the JavaScript URL result
     9        when the URL is set as href on an anchor (as opposed to the src of an iframe). This will be addressed separately.
     10
     11        * web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling-dynamic-expected.txt:
     12
    1132021-10-26  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling-dynamic-expected.txt

    r279427 r284934  
    11
    2 FAIL 0041 set in src="" assert_equals: expected "UTF-8" but got "windows-1252"
     2PASS 0041 set in src=""
    33FAIL 0041 set in href="" targeting a frame and clicked assert_equals: expected "A" but got ""
    4 FAIL 0080 00FF set in src="" assert_equals: expected "UTF-8" but got "windows-1252"
     4PASS 0080 00FF set in src=""
    55FAIL 0080 00FF set in href="" targeting a frame and clicked assert_equals: expected "€ÿ" but got ""
    6 FAIL 0080 00FF 0100 set in src="" assert_equals: expected "UTF-8" but got "windows-1252"
     6PASS 0080 00FF 0100 set in src=""
    77FAIL 0080 00FF 0100 set in href="" targeting a frame and clicked assert_equals: expected "€ÿĀ" but got ""
    8 FAIL D83D DE0D set in src="" assert_equals: expected "UTF-8" but got "windows-1252"
     8PASS D83D DE0D set in src=""
    99FAIL D83D DE0D set in href="" targeting a frame and clicked assert_equals: expected "😍" but got ""
    10 FAIL DE0D 0041 set in src="" assert_equals: expected "\ufffdA" but got "U+de0dA"
     10PASS DE0D 0041 set in src=""
    1111FAIL DE0D 0041 set in href="" targeting a frame and clicked assert_equals: expected "\ufffdA" but got ""
    1212
  • trunk/Source/WebCore/ChangeLog

    r284920 r284934  
     12021-10-27  Chris Dumez  <cdumez@apple.com>
     2
     3        JavaScript URL result should be treated as UTF-8 bytes
     4        https://bugs.webkit.org/show_bug.cgi?id=232380
     5
     6        Reviewed by Darin Adler.
     7
     8        JavaScript URL result should be treated as UTF-8 bytes:
     9        - https://github.com/whatwg/html/pull/6781
     10
     11        No new tests, rebaselined existing test.
     12
     13        * loader/DocumentWriter.cpp:
     14        (WebCore::DocumentWriter::replaceDocumentWithResultOfExecutingJavascriptURL):
     15
    1162021-10-27  Martin Robinson  <mrobinson@webkit.org>
    217
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r284857 r284934  
    12811281        }
    12821282
    1283         bool userChosen;
     1283        DocumentWriter::IsEncodingUserChosen userChosen;
    12841284        String encoding;
    12851285        if (overrideEncoding().isNull()) {
    1286             userChosen = false;
     1286            userChosen = DocumentWriter::IsEncodingUserChosen::No;
    12871287            encoding = response().textEncodingName();
    12881288#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
     
    12911291#endif
    12921292        } else {
    1293             userChosen = true;
     1293            userChosen = DocumentWriter::IsEncodingUserChosen::Yes;
    12941294            encoding = overrideEncoding();
    12951295        }
  • trunk/Source/WebCore/loader/DocumentWriter.cpp

    r284093 r284934  
    7878    begin(m_frame->document()->url(), true, ownerDocument);
    7979
     80    setEncoding("UTF-8"_s, IsEncodingUserChosen::No);
     81
    8082    // begin() might fire an unload event, which will result in a situation where no new document has been attached,
    8183    // and the old document has been detached. Therefore, bail out if no document is attached.
     
    8991        }
    9092
    91         // FIXME: This should call DocumentParser::appendBytes instead of append
    92         // to support RawDataDocumentParsers.
    93         if (DocumentParser* parser = m_frame->document()->parser())
    94             parser->append(source.impl());
     93        if (DocumentParser* parser = m_frame->document()->parser()) {
     94            auto utf8Source = source.utf8();
     95            parser->appendBytes(*this, reinterpret_cast<const uint8_t*>(utf8Source.data()), utf8Source.length());
     96        }
    9597    }
    9698
     
    307309}
    308310
    309 void DocumentWriter::setEncoding(const String& name, bool userChosen)
     311void DocumentWriter::setEncoding(const String& name, IsEncodingUserChosen isUserChosen)
    310312{
    311313    m_encoding = name;
    312     m_encodingWasChosenByUser = userChosen;
     314    m_encodingWasChosenByUser = isUserChosen == IsEncodingUserChosen::Yes;
    313315}
    314316
  • trunk/Source/WebCore/loader/DocumentWriter.h

    r278532 r284934  
    5454    void setFrame(Frame&);
    5555
    56     WEBCORE_EXPORT void setEncoding(const String& encoding, bool userChosen);
     56    enum class IsEncodingUserChosen : bool { No, Yes };
     57    WEBCORE_EXPORT void setEncoding(const String& encoding, IsEncodingUserChosen);
    5758
    5859    const String& mimeType() const { return m_mimeType; }
Note: See TracChangeset for help on using the changeset viewer.