Skip to content

Commit

Permalink
Update web-platform tests (#3203)
Browse files Browse the repository at this point in the history
Normative changes:

* Implement AbortSignal.abort()
* Normalize newlines in <textarea> form value according to the updated
  HTML spec:
  https://blog.whatwg.org/newline-normalizations-in-form-submission
* Implement <textarea> line wrapping

Other changes:

* Consistently terminate WPT server process with SIGINT
  • Loading branch information
ninevra committed Jun 15, 2021
1 parent 364c77d commit 346ea98
Show file tree
Hide file tree
Showing 9 changed files with 23,640 additions and 5,937 deletions.
7 changes: 7 additions & 0 deletions lib/jsdom/living/aborting/AbortSignal-impl.js
Expand Up @@ -3,6 +3,7 @@
const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor");
const { fireAnEvent } = require("../helpers/events");
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const AbortSignal = require("../generated/AbortSignal");

class AbortSignalImpl extends EventTargetImpl {
constructor(globalObject, args, privateData) {
Expand All @@ -15,6 +16,12 @@ class AbortSignalImpl extends EventTargetImpl {
this.abortAlgorithms = new Set();
}

static abort(globalObject) {
const abortSignal = AbortSignal.createImpl(globalObject, []);
abortSignal.aborted = true;
return abortSignal;
}

_signalAbort() {
if (this.aborted) {
return;
Expand Down
2 changes: 2 additions & 0 deletions lib/jsdom/living/aborting/AbortSignal.webidl
@@ -1,5 +1,7 @@
[Exposed=(Window,Worker)]
interface AbortSignal : EventTarget {
[WebIDL2JSCallWithGlobal, NewObject] static AbortSignal abort();

readonly attribute boolean aborted;

attribute EventHandler onabort;
Expand Down
7 changes: 0 additions & 7 deletions lib/jsdom/living/helpers/form-controls.js
Expand Up @@ -73,13 +73,6 @@ exports.isButton = formControl => {
formControl.namespaceURI === HTML_NS;
};

exports.normalizeToCRLF = string => {
return string.replace(/\r([^\n])/g, "\r\n$1")
.replace(/\r$/, "\r\n")
.replace(/([^\r])\n/g, "$1\r\n")
.replace(/^\n/, "\r\n");
};

// https://html.spec.whatwg.org/multipage/dom.html#interactive-content-2
exports.isInteractiveContent = node => {
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) {
Expand Down
34 changes: 31 additions & 3 deletions lib/jsdom/living/nodes/HTMLTextAreaElement-impl.js
Expand Up @@ -9,7 +9,7 @@ const { mixin } = require("../../utils");

const DOMException = require("domexception/webidl2js-wrapper");
const { cloningSteps } = require("../helpers/internal-constants");
const { isDisabled, normalizeToCRLF, getLabelsForLabelable, formOwner } = require("../helpers/form-controls");
const { isDisabled, getLabelsForLabelable, formOwner } = require("../helpers/form-controls");
const { childTextContent } = require("../helpers/text");
const { fireAnEvent } = require("../helpers/events");

Expand Down Expand Up @@ -38,8 +38,11 @@ class HTMLTextAreaElementImpl extends HTMLElementImpl {

// https://html.spec.whatwg.org/multipage/form-elements.html#textarea-wrapping-transformation
_getValue() {
// Hard-wrapping omitted, for now.
return normalizeToCRLF(this._rawValue);
const apiValue = this._getAPIValue();
const wrap = this.getAttributeNS(null, "wrap");
return wrap === "hard" ?
textareaWrappingTransformation(apiValue, this.cols) :
apiValue;
}

_childTextContentChangeSteps() {
Expand Down Expand Up @@ -242,3 +245,28 @@ mixin(HTMLTextAreaElementImpl.prototype, DefaultConstraintValidationImpl.prototy
module.exports = {
implementation: HTMLTextAreaElementImpl
};

function textareaWrappingTransformation(text, cols) {
let lineStart = 0;
let lineEnd = text.indexOf("\n");
if (lineEnd === -1) {
lineEnd = text.length;
}

while (lineStart < text.length) {
const lineLength = lineEnd - lineStart;
if (lineLength > cols) {
// split the line
lineEnd = lineStart + cols;
text = text.slice(0, lineEnd) + "\n" + text.slice(lineEnd);
}
// move to next line
lineStart = lineEnd + 1; // step over the newline
lineEnd = text.indexOf("\n", lineStart);
if (lineEnd === -1) {
lineEnd = text.length;
}
}

return text;
}
11 changes: 3 additions & 8 deletions lib/jsdom/living/xhr/FormData-impl.js
@@ -1,7 +1,7 @@
"use strict";
const idlUtils = require("../generated/utils");
const { closest } = require("../helpers/traversal");
const { isDisabled, isSubmittable, isButton, normalizeToCRLF } = require("../helpers/form-controls");
const { isDisabled, isSubmittable, isButton } = require("../helpers/form-controls");
const Blob = require("../generated/Blob.js");
const File = require("../generated/File.js");
const conversions = require("webidl-conversions");
Expand Down Expand Up @@ -145,8 +145,6 @@ function constructTheEntryList(form, submitter) {
appendAnEntry(entryList, name, field.files.item(i));
}
}
} /* skip plugins. TODO: _charset_ */ else if (field.localName === "textarea") {
appendAnEntry(entryList, name, field._getValue(), true);
} else {
appendAnEntry(entryList, name, field._getValue());
}
Expand All @@ -163,12 +161,9 @@ function constructTheEntryList(form, submitter) {
return entryList;
}

function appendAnEntry(entryList, name, value, preventLineBreakNormalization = false) {
name = conversions.USVString(normalizeToCRLF(name));
function appendAnEntry(entryList, name, value) {
name = conversions.USVString(name);
if (!File.isImpl(value)) {
if (!preventLineBreakNormalization) {
value = normalizeToCRLF(value);
}
value = conversions.USVString(value);
}
const entry = createAnEntry(name, value);
Expand Down
2 changes: 1 addition & 1 deletion test/web-platform-tests/run-wpts.js
Expand Up @@ -49,7 +49,7 @@ before({ timeout: 30 * 1000 }, async () => {
});

after(() => {
serverProcess.kill();
serverProcess.kill("SIGINT");
});

describe("web-platform-tests", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/web-platform-tests/tests
Submodule tests updated 3354 files
52 changes: 39 additions & 13 deletions test/web-platform-tests/to-run.yaml
Expand Up @@ -7,15 +7,17 @@ blob/Blob-constructor.any.html:
"Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).": [fail, Depends on MessagePort]
blob/Blob-stream.any.html: [fail, Unknown]
blob/Blob-text.any.html: [fail, Depends on TextEncoder]
file/File-constructor.any.html: [needs-node12, Requires globalThis]
file/send-file-form*: [fail, DataTransfer not implemented]
fileReader.any.html: [needs-node12, Requires globalThis]
filelist-section/filelist.html:
"Check if item is a instanceof Function": [fail, function is not instanceof Function]
historical.https.html:
"Service worker test setup": [fail, Needs Service Worker implementation]
idlharness.html: [fail, URL.createObjectURL not implemented]
reading-data-section/FileReader-multiple-reads.html: [timeout, Unknown; spews tons of zeros on the screen when failing]
reading-data-section/FileReader-multiple-reads.any.html: [timeout, Unknown; spews tons of zeros on the screen when failing]
reading-data-section/filereader_events.any.html: [fail, Unknown]
reading-data-section/filereader_result.html:
reading-data-section/filereader_result.any.html:
'result is null during "loadstart" event for readAsText': [fail, Unknown]
'result is null during "loadstart" event for readAsDataURL': [fail, Unknown]
'result is null during "loadstart" event for readAsArrayBuffer': [fail, Unknown]
Expand Down Expand Up @@ -84,6 +86,7 @@ elementFromPosition.html: [fail, Unknown]
elementScroll.html: [fail, Unknown]
elementsFromPoint**: [fail, Not implemented]
getBoundingClientRect-empty-inline.html: [fail, document.fonts is not implemented]
getBoundingClientRect-shy.html: [fail, Not implemented]
getClientRects-br-*: [fail, Not implemented]
getClientRects-inline-atomic-child.html: [fail, Not implemented]
idlharness.html: [fail, Depends on Fetch]
Expand Down Expand Up @@ -171,8 +174,6 @@ throw-on-dynamic-markup-insertion-counter-reactions.html: [timeout, document.ope

DIR: dom/abort

event.any.html: [fail, AbortSignal.abort() not implemented]

---

DIR: dom/collections
Expand All @@ -185,6 +186,7 @@ AddEventListenerOptions-signal.any.html: [fail, Not implemented]
Event-dispatch-click.tentative.html: [fail, Test is wrong, https://github.com/web-platform-tests/wpt/issues/27819]
Event-isTrusted.any.html: [fail, Unknown]
Event-timestamp-high-resolution.html: [fail, Not implemented]
Event-timestamp-high-resolution.https.html: [fail, Not implemented]
EventListener-incumbent-global-1.sub.html: [timeout, Multi-globals]
EventListener-incumbent-global-2.sub.html: [timeout, Multi-globals]
EventListener-invoke-legacy.html: [timeout, Animation stuff not implemented]
Expand Down Expand Up @@ -270,6 +272,8 @@ headers-record.any.html: [needs-node12, V8 bug fixed in Node 12 onward]

DIR: hr-time

clamped-time-origin-isolated.https.html: [fail, Needs crossOriginIsolated]
clamped-time-origin.html: [fail, Needs crossOriginIsolated]
cross-origin-isolated-timing-attack.https.html: [fail, Not implemented]
idlharness.any.html: [fail, Depends on fetch]
performance-tojson.html: [fail, PerformanceTiming and PerformanceNavigation are not implemented]
Expand Down Expand Up @@ -317,6 +321,7 @@ DIR: html/browsers/browsing-the-web/navigating-across-documents
014.html: [fail, Unknown]
015.html: [fail, Unknown]
abort-document-load.html: [fail, Unknown]
about-srcdoc-navigation-blocked.html: [timeout, Unknown]
anchor-fragment-**.html: [timeout, Unknown]
anchor-jsurl-form-submit.html: [timeout, Unknown]
child-navigates-parent-same-origin.window.html: [fail-slow, Unknown]
Expand Down Expand Up @@ -369,6 +374,8 @@ history_properties_only_fully_active.html: [fail, Unknown]
iframe_history_go_0.html: [timeout, Unknown]
joint_session_history/001.html: [timeout, Unknown]
joint_session_history/002.html: [timeout, Unknown]
traverse-during-beforeunload.html: [timeout, Unknown]
traverse-during-unload.html: [timeout, Unknown]
traverse_the_history_1.html: [timeout, Unknown]
traverse_the_history_2.html: [timeout, Unknown]
traverse_the_history_3.html: [timeout, Unknown]
Expand Down Expand Up @@ -451,6 +458,7 @@ proxy-getOwnPropertyDescriptor.html:
'Window target, no trap, "name" attribute': [fail, Incorrectly implemented as a data property]
security-window/window-security.https.html: [fail, Exoticness of Window not implemented]
self-et-al.window.html: [fail, Depends on window.open() and window.closed]
window-indexed-properties-delete-no-cache.html: [fail-slow, deleting window indexed properties should fail to remove iframes]
window-indexed-properties-strict.html: [flaky, "
Errors in `process.nextTick` callback:
Uncaught TypeError: this[i].close is not a function
Expand Down Expand Up @@ -551,7 +559,6 @@ auxiliary-browsing-contexts/opener.html: [timeout, Unknown]
browsing-context-names/**: [timeout, Not implemented]
browsing-context.html: [fail, Unknown]
clear-window-name.https.html: [fail, Unknown]
document-access/**: [fail, Not implemented]
document-domain-nested-navigate.window.html: [fail, Unknown]
embedded-opener-a-form.html: [timeout, Opener not implemented]
embedded-opener-remove-frame.html: [timeout, Opener not implemented]
Expand Down Expand Up @@ -752,6 +759,7 @@ historical-progress-event.window.html: [needs-canvas]
image-base-url.html: [timeout, <base> not implemented]
image-loading-eager.html: [needs-canvas, Unimplemented and pass with canvas]
image-loading-lazy**: [fail-slow, loading attr not implemented]
img-picture-ancestor.html: [fail, Unknown; possibly needs media queries?]
img.complete.html: [timeout, Unknown]
invalid-src.html: [timeout, Resource loader doesn't catch bad URLs at the right point in the process]
invisible-image.html: [fail, images block the window load event not implemented (images not in _queue)]
Expand All @@ -767,6 +775,7 @@ picture-loading-lazy.html: [fail, scrollIntoView not implemented, loading attr n
relevant-mutations.html: [timeout, Unknown]
remove-element-and-scroll.html: [timeout, scrollIntoView not implemented]
sizes/**: [timeout, Unimplemented]
source-media-outside-doc.html: [fail, Unknown; possibly needs media queries?]
srcset/**: [timeout, Unimplemented]
update-media.html: [timeout, Unimplemented]
update-src-complete.html: [needs-canvas]
Expand Down Expand Up @@ -971,7 +980,6 @@ execution-timing/043.html: [fail, Unknown]
execution-timing/044.html: [fail, Unknown]
execution-timing/045.html: [fail, Unknown]
execution-timing/048.html: [fail, Unknown]
execution-timing/050.html: [fail, Unknown]
execution-timing/052.html: [fail, Unknown]
execution-timing/054.html: [fail, Unknown]
execution-timing/055.html: [fail, Unknown]
Expand Down Expand Up @@ -1116,6 +1124,9 @@ parsing/html_content_in_foreign_context.html: [fail, Parser issues with foreign
parsing/unclosed-svg-script.html: [fail, Unknown]
serializing-html-fragments/escaping.html: [fail, https://github.com/inikulin/parse5/issues/332]
serializing-html-fragments/serializing.html: [fail, https://github.com/inikulin/parse5/issues/289]
xmldecl/xmldecl-1.html: [fail, Unknown; possibly iframes are inheriting encoding from their parent?]
xmldecl/xmldecl-2.html: [fail, several encodings misdetected?]
xmldecl/xmldecl-3.html: [fail, Unknown]

---

Expand Down Expand Up @@ -1166,7 +1177,6 @@ messageevent-constructor.https.html: [fail, uses MessageChannel]
DIR: html/webappapis/system-state-and-capabilities/the-navigator-object

historical.https.window.html: [fail, Not implemented]
navigator-pluginarray.html: [fail, https://github.com/jsdom/jsdom/issues/2727#issuecomment-787559889]
navigator-window-controls-overlay.html: [fail, Not implemented]
navigator_user_agent.https.html: [fail, Not implemented]
protocol.https.html: [fail, registerProtocolHandler() is not implemented]
Expand Down Expand Up @@ -1200,16 +1210,25 @@ Document-prototype-currentScript.html: [timeout, Test not up to date next with u
DocumentOrShadowRoot-prototype-elementFromPoint.html: [fail, offsetTop not implemented]
MouseEvent-prototype-offsetX-offsetY.html: [fail, offsetTop not implemented]
ShadowRoot-interface.html: [fail, shadowRoot.styleSheet is not yet implemented]
declarative/**: [fail, Not implemented]
declarative/declarative-after-attachshadow.tentative.html: [fail, Not implemented]
declarative/declarative-shadow-dom-attachment.tentative.html: [fail, Not implemented]
declarative/declarative-shadow-dom-basic.tentative.html: [fail, Not implemented]
declarative/declarative-shadow-dom-opt-in.tentative.html: [fail, Not implemented]
declarative/getinnerhtml.tentative.html: [fail, Not implemented]
declarative/innerhtml-before-closing-tag.tentative.html: [fail, Not implemented]
declarative/innerhtml-on-ordinary-template.tentative.html: [fail, Not implemented]
declarative/move-template-before-closing-tag.tentative.html: [fail, Not implemented]
declarative/script-access.tentative.html: [fail, Not implemented]
focus/ShadowRoot-delegatesFocus.html: [fail, DelegatesFocus is not implemented]
focus/focus-pseudo-matches-on-shadow-host.html: [timeout, Seems to depend on autofocus]
focus/focus-selector-delegatesFocus.html: [fail, Not implemented]
form-control-form-attribute.html: [fail, Form association doesn't respect the spec]
imperative-slot-api-slotchange.html: [fail, Imperative slot API is not implemented]
imperative-slot-api.html: [fail, Imperative slot API is not implemented]
leaktests/html-collection.html: [fail, Document.all is not implemented]
leaktests/window-frames.html: [fail, Window.name is not implemeneted]
offsetParent-across-shadow-boundaries.html: [fail, offsetParent not implemented]
scroll-to-the-fragment-in-shadow-tree.html: [fail, Requires a layout engine]
slots-imperative-api-slotchange.tentative.html: [fail, Unknown]
slots-imperative-slot-api.tentative.html: [fail, Unknown (browsers also fail now)]
untriaged/elements-and-dom-objects/shadowroot-object/shadowroot-attributes/test-011.html: [fail, ShadowRoot.stylesheets is not implemented]
untriaged/elements-and-dom-objects/shadowroot-object/shadowroot-methods/test-004.html: [fail, https://github.com/w3c/selection-api/issues/114]
untriaged/elements-and-dom-objects/shadowroot-object/shadowroot-methods/test-006.html: [fail, DocumentOrShadowRoot.elementFromPoint() is not implemented. Needs layout engine]
Expand Down Expand Up @@ -1248,20 +1267,25 @@ percent-encoding.window.html: [fail, Depends on fetch]
toascii.window.html: [fail, Depends on fetch]
url-constructor.any.html: [fail, Depends on fetch]
url-origin.any.html: [fail, Depends on fetch]
url-setters.html: [fail, Depends on fetch]
url-setters-a-area.window.html: [fail, Depends on fetch]
url-setters.any.html: [fail, Depends on fetch]
urlencoded-parser.any.html: [fail, Depends on fetch]

---

DIR: websockets

"**/**?wpt_flags=h2": [fail-slow, HTTP/2 web sockets not implemented]
Create-Secure-extensions-empty.any.html: [timeout, Buggy test as the test does not take into account the mandatory permessage-deflate extension]
"*.any.sharedworker.html?wss": [fail-slow, Needs SharedWorker implementation]
"*.any.worker.html?wss": [fail-slow, Needs Worker implementation]
Create-blocked-port.any.html: [fail-slow, Not implemented]
Create-on-worker-shutdown.any.html: [fail, Needs Worker implementation]
Send-data.worker.html?wss: [fail-slow, Needs Worker implementation]
basic-auth.any.serviceworker.html?wss: [fail-slow, Unknown]
cookies/third-party-cookie-accepted.https.html: [fail, 'https://github.com/salesforce/tough-cookie/issues/80']
interfaces/WebSocket/close/close-connecting.html*: [fail, Potentially buggy test as Chrome fails it too]
remove-own-iframe-during-onerror.window.html: [timeout, iframe.srcdoc not implemented]
remove-own-iframe-during-onerror.window.html?wss: [timeout, iframe.srcdoc not implemented]
stream/tentative/*: [fail, This is not yet standardised and browsers should not be expected to pass these tests.]
unload-a-document/*: [timeout, Requires window.open]

Expand Down Expand Up @@ -1301,7 +1325,9 @@ data-uri.htm: [fail, Unknown]
event-error-order.sub.html: [fail, Unknown]
event-timeout-order.any.html: [fail, Unknown]
event-upload-progress.any.html: [fail, Unknown]
formdata.htm: [fail, FormDataEvent is not implemented]
formdata.html:
"Newly created FormData contains entries added to \"formData\" IDL attribute of FormDataEvent.": [fail, FormDataEvent not implemented]
"|new FormData()| in formdata event handler should throw": [fail, FormDataEvent not implemented]
getallresponseheaders.htm: [fail, Unknown]
getresponseheader.any.html: [fail, Unknown]
headers-normalize-response.htm: [timeout, Unknown]
Expand Down

0 comments on commit 346ea98

Please sign in to comment.