Changeset 270010 in webkit


Ignore:
Timestamp:
Nov 18, 2020 7:40:20 PM (3 years ago)
Author:
Chris Dumez
Message:

Resync web-platform-tests/FileAPI tests from upstream
https://bugs.webkit.org/show_bug.cgi?id=219125

Reviewed by Sam Weinig.

Resync web-platform-tests/FileAPI tests from upstream dd35c2b21b76772123f7.

  • web-platform-tests/FileAPI/file/File-constructor-expected.txt:
  • web-platform-tests/FileAPI/file/File-constructor.html:
  • web-platform-tests/FileAPI/file/resources/echo-content-escaped.py: Added.

(escape_byte):
(main):

  • web-platform-tests/FileAPI/file/resources/w3c-import.log: Added.
  • web-platform-tests/FileAPI/file/send-file-form-controls.tentative-expected.txt: Added.
  • web-platform-tests/FileAPI/file/send-file-form-controls.tentative.html: Added.
  • web-platform-tests/FileAPI/file/send-file-form-punctuation.tentative-expected.txt: Added.
  • web-platform-tests/FileAPI/file/send-file-form-punctuation.tentative.html: Added.
  • web-platform-tests/FileAPI/file/send-file-form-utf-8.html:
  • web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative.html:
  • web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative.html:
  • web-platform-tests/FileAPI/file/send-file-formdata-controls.tentative-expected.txt: Added.
  • web-platform-tests/FileAPI/file/send-file-formdata-controls.tentative.html: Added.
  • web-platform-tests/FileAPI/file/send-file-formdata-expected.txt: Added.
  • web-platform-tests/FileAPI/file/send-file-formdata-punctuation.tentative-expected.txt: Added.
  • web-platform-tests/FileAPI/file/send-file-formdata-punctuation.tentative.html: Added.
  • web-platform-tests/FileAPI/file/send-file-formdata-utf-8-expected.txt: Added.
  • web-platform-tests/FileAPI/file/send-file-formdata-utf-8.html: Added.
  • web-platform-tests/FileAPI/file/send-file-formdata.html: Added.
  • web-platform-tests/FileAPI/file/w3c-import.log:
  • web-platform-tests/FileAPI/fileReader-expected.txt:
  • web-platform-tests/FileAPI/fileReader.html:
  • web-platform-tests/FileAPI/support/send-file-form-helper.js:

(escapeString):
(const.formPostFileUploadTest):

  • web-platform-tests/FileAPI/support/send-file-formdata-helper.js: Added.

(const.formDataPostFileUploadTest):

  • web-platform-tests/FileAPI/support/w3c-import.log:
  • web-platform-tests/FileAPI/url/url-charset.window-expected.txt: Added.
  • web-platform-tests/FileAPI/url/url-charset.window.html: Added.
  • web-platform-tests/FileAPI/url/url-charset.window.js: Added.

(async_test.t.t.add_cleanup):
(async_test.t.win.onload.t.step_func_done):

  • web-platform-tests/FileAPI/url/w3c-import.log:
Location:
trunk/LayoutTests
Files:
19 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/TestExpectations

    r270009 r270010  
    26872687webkit.org/b/172099 imported/w3c/web-platform-tests/FileAPI/url/url_xmlhttprequest_img.html [ ImageOnlyFailure ]
    26882688imported/w3c/web-platform-tests/FileAPI/url/sandboxed-iframe.html [ Failure ]
     2689# Test output contains WebKitFormBoundary lines with randomly generated text.
     2690imported/w3c/web-platform-tests/FileAPI/file/send-file-formdata-controls.tentative.html [ Failure ]
    26892691
    26902692# Secure Contexts tests that timeout
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r270009 r270010  
     12020-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Resync web-platform-tests/FileAPI tests from upstream
     4        https://bugs.webkit.org/show_bug.cgi?id=219125
     5
     6        Reviewed by Sam Weinig.
     7
     8        Resync web-platform-tests/FileAPI tests from upstream dd35c2b21b76772123f7.
     9
     10        * web-platform-tests/FileAPI/file/File-constructor-expected.txt:
     11        * web-platform-tests/FileAPI/file/File-constructor.html:
     12        * web-platform-tests/FileAPI/file/resources/echo-content-escaped.py: Added.
     13        (escape_byte):
     14        (main):
     15        * web-platform-tests/FileAPI/file/resources/w3c-import.log: Added.
     16        * web-platform-tests/FileAPI/file/send-file-form-controls.tentative-expected.txt: Added.
     17        * web-platform-tests/FileAPI/file/send-file-form-controls.tentative.html: Added.
     18        * web-platform-tests/FileAPI/file/send-file-form-punctuation.tentative-expected.txt: Added.
     19        * web-platform-tests/FileAPI/file/send-file-form-punctuation.tentative.html: Added.
     20        * web-platform-tests/FileAPI/file/send-file-form-utf-8.html:
     21        * web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative.html:
     22        * web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative.html:
     23        * web-platform-tests/FileAPI/file/send-file-formdata-controls.tentative-expected.txt: Added.
     24        * web-platform-tests/FileAPI/file/send-file-formdata-controls.tentative.html: Added.
     25        * web-platform-tests/FileAPI/file/send-file-formdata-expected.txt: Added.
     26        * web-platform-tests/FileAPI/file/send-file-formdata-punctuation.tentative-expected.txt: Added.
     27        * web-platform-tests/FileAPI/file/send-file-formdata-punctuation.tentative.html: Added.
     28        * web-platform-tests/FileAPI/file/send-file-formdata-utf-8-expected.txt: Added.
     29        * web-platform-tests/FileAPI/file/send-file-formdata-utf-8.html: Added.
     30        * web-platform-tests/FileAPI/file/send-file-formdata.html: Added.
     31        * web-platform-tests/FileAPI/file/w3c-import.log:
     32        * web-platform-tests/FileAPI/fileReader-expected.txt:
     33        * web-platform-tests/FileAPI/fileReader.html:
     34        * web-platform-tests/FileAPI/support/send-file-form-helper.js:
     35        (escapeString):
     36        (const.formPostFileUploadTest):
     37        * web-platform-tests/FileAPI/support/send-file-formdata-helper.js: Added.
     38        (const.formDataPostFileUploadTest):
     39        * web-platform-tests/FileAPI/support/w3c-import.log:
     40        * web-platform-tests/FileAPI/url/url-charset.window-expected.txt: Added.
     41        * web-platform-tests/FileAPI/url/url-charset.window.html: Added.
     42        * web-platform-tests/FileAPI/url/url-charset.window.js: Added.
     43        (async_test.t.t.add_cleanup):
     44        (async_test.t.win.onload.t.step_func_done):
     45        * web-platform-tests/FileAPI/url/w3c-import.log:
     46
    1472020-11-18  Chris Dumez  <cdumez@apple.com>
    248
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/File-constructor-expected.txt

    r267651 r270010  
    2424PASS Bits argument: object that throws
    2525PASS Using fileName
    26 FAIL Using special character in fileName assert_equals: expected "dummy:foo" but got "dummy/foo"
     26PASS No replacement when using special character in fileName
    2727PASS Using null fileName
    2828PASS Using number fileName
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/File-constructor.html

    r263059 r270010  
    8585
    8686test_second_argument("dummy", "dummy", "Using fileName");
    87 test_second_argument("dummy/foo", "dummy:foo", "Using special character in fileName");
     87test_second_argument("dummy/foo", "dummy/foo",
     88                     "No replacement when using special character in fileName");
    8889test_second_argument(null, "null", "Using null fileName");
    8990test_second_argument(1, "1", "Using number fileName");
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-utf-8.html

    r232641 r270010  
    2828  formEncoding: 'UTF-8',
    2929  expectedEncodedBaseName: (
    30       'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt'),
     30      'file-for-upload-in-form-\xEF\x9F\xB0\xEF\x9E\x93\xEF\x9E\x83\xEF\x9E\xA0.txt'),
    3131});
    3232
     
    3535  fileBaseName: 'file-for-upload-in-form-☺😂.txt',
    3636  formEncoding: 'UTF-8',
    37   expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt',
     37  expectedEncodedBaseName: (
     38      'file-for-upload-in-form-\xC3\xA2\xCB\x9C\xC2\xBA\xC3\xB0\xC5\xB8\xCB\x9C\xE2\x80\x9A.txt'),
    3839});
    3940
     
    4243  fileBaseName: 'file-for-upload-in-form-★星★.txt',
    4344  formEncoding: 'UTF-8',
    44   expectedEncodedBaseName: 'file-for-upload-in-form-★星★.txt',
     45  expectedEncodedBaseName: 'file-for-upload-in-form-\xE2\x98\x85\xE6\x98\x9F\xE2\x98\x85.txt',
    4546});
    4647
     
    4950  fileBaseName: 'file-for-upload-in-form-☺😂.txt',
    5051  formEncoding: 'UTF-8',
    51   expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt',
     52  expectedEncodedBaseName: 'file-for-upload-in-form-\xE2\x98\xBA\xF0\x9F\x98\x82.txt',
    5253});
    5354
     
    5657  fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`,
    5758  formEncoding: 'UTF-8',
    58   expectedEncodedBaseName: `file-for-upload-in-form-${kTestChars}.txt`,
     59  expectedEncodedBaseName: `file-for-upload-in-form-${kTestFallbackUtf8}.txt`,
    5960});
    6061
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative.html

    r232641 r270010  
    3434  fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt',
    3535  formEncoding: 'windows-1252',
    36   expectedEncodedBaseName: (
    37       'file-for-upload-in-form-&#63472;&#63379;&#63363;&#63392;.txt'),
     36  expectedEncodedBaseName: 'file-for-upload-in-form-&#63472;&#63379;&#63363;&#63392;.txt',
    3837});
    3938
     
    4241  fileBaseName: 'file-for-upload-in-form-☺😂.txt',
    4342  formEncoding: 'windows-1252',
    44   expectedEncodedBaseName: 'file-for-upload-in-form-☺😂.txt',
     43  expectedEncodedBaseName: 'file-for-upload-in-form-\xE2\x98\xBA\xF0\x9F\x98\x82.txt',
    4544});
    4645
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative.html

    r232641 r270010  
    3434  fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt',
    3535  formEncoding: 'x-user-defined',
    36   expectedEncodedBaseName: 'file-for-upload-in-form-𓃠.txt',
     36  expectedEncodedBaseName: 'file-for-upload-in-form-\xF0\x93\x83\xA0.txt',
    3737});
    3838
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/w3c-import.log

    r263059 r270010  
    1818/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/File-constructor.html
    1919/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/Worker-read-file-constructor.worker.js
     20/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-controls.tentative.html
    2021/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-iso-2022-jp.tentative.html
     22/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-punctuation.tentative.html
    2123/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-utf-8.html
    2224/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative.html
    2325/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative.html
    2426/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form.html
     27/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-formdata-controls.tentative.html
     28/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-formdata-punctuation.tentative.html
     29/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-formdata-utf-8.html
     30/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-formdata.html
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/fileReader-expected.txt

    r268054 r270010  
    44PASS FileReader States -- abort
    55PASS FileReader States -- events
    6 PASS FileReader States -- abort during progress
    76
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/fileReader.html

    r268054 r270010  
    3636                t_abort.done();
    3737            });
    38             fileReader.onerror = this.unreached_func("onerror should not be called when abort is called");
    3938            fileReader.abort();
    4039            fileReader.onabort = this.unreached_func("abort event should fire sync")
     
    6463            });
    6564        });
    66 
    67         var t_abort_during_progress = async_test("FileReader States -- abort during progress");
    68         t_abort_during_progress.step(function() {
    69             var fileReader = new FileReader();
    70 
    71             var blob = new Blob([1]);
    72             fileReader.readAsArrayBuffer(blob);
    73 
    74             var onprogressCalled = false;
    75             fileReader.onprogress = this.step_func(function(e) {
    76                 onprogressCalled = true;
    77                 fileReader.abort();
    78             });
    79 
    80             fileReader.onabort = this.step_func(function(e) {
    81                 assert_unreached("onabort should not be called if abort is called during final onprogress");
    82             });
    83 
    84             fileReader.onloadend = this.step_func(function(e) {
    85                 assert_true(onprogressCalled, "onprogress should be called before onloadend");
    86                 setTimeout(function() {
    87                     t_abort_during_progress.done();
    88                 }, 0);
    89             });
    90         });
    9165    </script>
    9266  </body>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/support/send-file-form-helper.js

    r232641 r270010  
    11'use strict';
     2
     3// See /FileAPI/file/resources/echo-content-escaped.py
     4function escapeString(string) {
     5  return string.replace(/\\/g, "\\\\").replace(
     6    /[^\x20-\x7E]/g,
     7    (x) => {
     8      let hex = x.charCodeAt(0).toString(16);
     9      if (hex.length < 2) hex = "0" + hex;
     10      return `\\x${hex}`;
     11    },
     12  ).replace(/\\x0d\\x0a/g, "\r\n");
     13}
    214
    315// Rationale for this particular test character sequence, which is
     
    7385const kTestChars = 'ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ';
    7486
    75 // NOTE: The expected interpretation of ISO-2022-JP according to
    76 // https://encoding.spec.whatwg.org/#iso-2022-jp-encoder unifies
    77 // single-byte and double-byte katakana.
    78 const kTestFallbackIso2022jp =
    79       ('ABC~\x1B(J~\\≈¤\x1B$B!&!&\x1B(B•∙·☼\x1B$B!z@1\x1B(B🌟' +
    80        '\x1B$B@1!z\x1B(B☼·∙•\x1B$B!&!&\x1B(B¤≈\x1B(J\\~\x1B(B~XYZ').replace(
    81              /[^\0-\x7F]/gu,
    82            x => `&#${x.codePointAt(0)};`);
    83 
    84 // NOTE: \uFFFD is used here to replace Windows-1252 bytes to match
    85 // how we will see them in the reflected POST bytes in a frame using
    86 // UTF-8 byte interpretation. The bytes will actually be intact, but
    87 // this code cannot tell and does not really care.
    88 const kTestFallbackWindows1252 =
    89       'ABC~‾\xA5≈\xA4・・\x95∙\xB7☼★星🌟星★☼\xB7∙\x95・・\xA4≈\xA5‾~XYZ'.replace(
    90             /[^\0-\xFF]/gu,
    91           x => `&#${x.codePointAt(0)};`).replace(/[\x80-\xFF]/g, '\uFFFD');
    92 
    93 const kTestFallbackXUserDefined =
    94       kTestChars.replace(/[^\0-\x7F]/gu, x => `&#${x.codePointAt(0)};`);
     87// The kTestFallback* strings represent the expected byte sequence from
     88// encoding kTestChars with the given encoding with "html" replacement
     89// mode, isomorphic-decoded. That means, characters that can't be
     90// encoded in that encoding get HTML-escaped, but no further
     91// `escapeString`-like escapes are needed.
     92const kTestFallbackUtf8 = (
     93  "ABC~\xE2\x80\xBE\xC2\xA5\xE2\x89\x88\xC2\xA4\xEF\xBD\xA5\xE3\x83\xBB\xE2" +
     94    "\x80\xA2\xE2\x88\x99\xC2\xB7\xE2\x98\xBC\xE2\x98\x85\xE6\x98\x9F\xF0\x9F" +
     95    "\x8C\x9F\xE6\x98\x9F\xE2\x98\x85\xE2\x98\xBC\xC2\xB7\xE2\x88\x99\xE2\x80" +
     96    "\xA2\xE3\x83\xBB\xEF\xBD\xA5\xC2\xA4\xE2\x89\x88\xC2\xA5\xE2\x80\xBE~XYZ"
     97);
     98
     99const kTestFallbackIso2022jp = (
     100  ("ABC~\x1B(J~\\≈¤\x1B$B!&!&\x1B(B•∙·☼\x1B$B!z@1\x1B(B🌟" +
     101    "\x1B$B@1!z\x1B(B☼·∙•\x1B$B!&!&\x1B(B¤≈\x1B(J\\~\x1B(B~XYZ")
     102    .replace(/[^\0-\x7F]/gu, (x) => `&#${x.codePointAt(0)};`)
     103);
     104
     105const kTestFallbackWindows1252 = (
     106  "ABC~‾\xA5≈\xA4・・\x95∙\xB7☼★星🌟星★☼\xB7∙\x95・・\xA4≈\xA5‾~XYZ".replace(
     107    /[^\0-\xFF]/gu,
     108    (x) => `&#${x.codePointAt(0)};`,
     109  )
     110);
     111
     112const kTestFallbackXUserDefined = kTestChars.replace(
     113  /[^\0-\x7F]/gu,
     114  (x) => `&#${x.codePointAt(0)};`,
     115);
    95116
    96117// formPostFileUploadTest - verifies multipart upload structure and
    97118// numeric character reference replacement for filenames, field names,
    98 // and field values.
    99 //
    100 // Uses /fetch/api/resources/echo-content.py to echo the upload
    101 // POST with UTF-8 byte interpretation, leading to the "UTF-8 goggles"
    102 // behavior documented below for expectedEncodedBaseName when non-
    103 // UTF-8-compatible byte sequences appear in the formEncoding-encoded
    104 // uploaded data.
     119// and field values using form submission.
     120//
     121// Uses /FileAPI/file/resources/echo-content-escaped.py to echo the
     122// upload POST with controls and non-ASCII bytes escaped. This is done
     123// because navigations whose response body contains [\0\b\v] may get
     124// treated as a download, which is not what we want. Use the
     125// `escapeString` function to replicate that kind of escape (note that
     126// it takes an isomorphic-decoded string, not a byte sequence).
    105127//
    106128// Fields in the parameter object:
     
    115137//   test file. Used in the test name.
    116138// - expectedEncodedBaseName: the expected formEncoding-encoded
    117 //   version of fileBaseName with unencodable characters replaced by
    118 //   numeric character references and non-7-bit-ASCII bytes seen
    119 //   through UTF-8 goggles; subsequences not interpretable as UTF-8
    120 //   have each byte represented here by \uFFFD REPLACEMENT CHARACTER.
     139//   version of fileBaseName, isomorphic-decoded. That means, characters
     140//   that can't be encoded in that encoding get HTML-escaped, but no
     141//   further `escapeString`-like escapes are needed.
    121142const formPostFileUploadTest = ({
    122143  fileNameSource,
     
    141162    const form = Object.assign(document.createElement('form'), {
    142163      acceptCharset: formEncoding,
    143       action: '/fetch/api/resources/echo-content.py',
     164      action: '/FileAPI/file/resources/echo-content-escaped.py',
    144165      method: 'POST',
    145166      enctype: 'multipart/form-data',
     
    195216      // verifies that assumption.
    196217      assert_equals(
    197           fileInput.files[0].name,
     218          baseNameOfFilePath(fileInput.files[0].name),
    198219          baseNameOfFilePath(fileInput.value),
    199220          `The basename of the field's value should match its files[0].name`);
     
    220241             JSON.stringify(formDataText)
    221242           }`);
     243
     244    const asValue = expectedEncodedBaseName.replace(/\r\n?|\n/g, "\r\n");
     245    const asName = asValue.replace(/[\r\n"]/g, encodeURIComponent);
     246    const asFilename = expectedEncodedBaseName.replace(/[\r\n"]/g, encodeURIComponent);
     247
     248    // The response body from echo-content-escaped.py has controls and non-ASCII
     249    // bytes escaped, so any caller-provided field that might contain such bytes
     250    // must be passed to `escapeString`, after any other expected
     251    // transformations.
    222252    const expectedText = [
    223253      boundary,
     
    228258      'Content-Disposition: form-data; name="filename"',
    229259      '',
    230       expectedEncodedBaseName,
    231       boundary,
    232       `Content-Disposition: form-data; name="${expectedEncodedBaseName}"`,
     260      // Unlike for names and filenames, multipart/form-data values don't escape
     261      // \r\n linebreaks, and when they're read from an iframe they become \n.
     262      escapeString(asValue).replace(/\r\n/g, "\n"),
     263      boundary,
     264      `Content-Disposition: form-data; name="${escapeString(asName)}"`,
    233265      '',
    234266      'filename',
    235267      boundary,
    236268      `Content-Disposition: form-data; name="file"; ` +
    237           `filename="${expectedEncodedBaseName}"`,
     269          `filename="${escapeString(asFilename)}"`,
    238270      'Content-Type: text/plain',
    239271      '',
    240       kTestChars,
     272      escapeString(kTestFallbackUtf8),
    241273      boundary + '--',
    242274    ].join('\n');
     275
    243276    assert_true(
    244277        formDataText.startsWith(expectedText),
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/support/w3c-import.log

    r263059 r270010  
    2020/LayoutTests/imported/w3c/web-platform-tests/FileAPI/support/incumbent.sub.html
    2121/LayoutTests/imported/w3c/web-platform-tests/FileAPI/support/send-file-form-helper.js
     22/LayoutTests/imported/w3c/web-platform-tests/FileAPI/support/send-file-formdata-helper.js
    2223/LayoutTests/imported/w3c/web-platform-tests/FileAPI/support/upload.txt
    2324/LayoutTests/imported/w3c/web-platform-tests/FileAPI/support/url-origin.html
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/w3c-import.log

    r263059 r270010  
    1919/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/sandboxed-iframe.html
    2020/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/unicode-origin.sub.html
     21/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/url-charset.window.js
    2122/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/url-format.any.js
    2223/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/url-in-tags-revoke.window.js
Note: See TracChangeset for help on using the changeset viewer.