Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit f9d3f0a

Browse files
keithamuslutien
authored andcommitted
Bug 1966338 [wpt PR 52527] - add tests for canonicalisation of the video preload attribute,
Automatic update from web-platform-tests add tests for canonicalisation of the video preload attribute (#52527) -- wpt-commits: 3b98b229846386fa60eec6ecb6ef93074033c4c5 wpt-pr: 52527 Differential Revision: https://phabricator.services.mozilla.com/D250623
1 parent 47e2efc commit f9d3f0a

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

testing/web-platform/tests/html/dom/elements-embedded.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ var embeddedElements = {
8888
// HTMLMediaElement
8989
src: "url",
9090
crossOrigin: {type: "enum", keywords: ["anonymous", "use-credentials"], nonCanon:{"": "anonymous"}, isNullable: true, defaultVal: null, invalidVal: "anonymous"},
91-
// As with "keytype", we have no missing value default defined here.
92-
preload: {type: "enum", keywords: ["none", "metadata", "auto"], nonCanon: {"": "auto"}, defaultVal: null},
91+
// Missing/Invalid value is implementation defined but must be one of the keywords
92+
preload: {type: "enum", keywords: ["none", "metadata", "auto"], nonCanon: {"": "auto"}, defaultVal: ["none", "metadata", "auto"]},
9393
autoplay: "boolean",
9494
loop: "boolean",
9595
controls: "boolean",
@@ -105,8 +105,8 @@ var embeddedElements = {
105105
// HTMLMediaElement
106106
src: "url",
107107
crossOrigin: {type: "enum", keywords: ["anonymous", "use-credentials"], nonCanon:{"": "anonymous"}, isNullable: true, defaultVal: null, invalidVal: "anonymous"},
108-
// As with "keytype", we have no missing value default defined here.
109-
preload: {type: "enum", keywords: ["none", "metadata", "auto"], nonCanon: {"": "auto"}, defaultVal: null},
108+
// Missing/Invalid value is implementation defined but must be one of the keywords
109+
preload: {type: "enum", keywords: ["none", "metadata", "auto"], nonCanon: {"": "auto"}, defaultVal: ["none", "metadata", "auto"]},
110110
autoplay: "boolean",
111111
loop: "boolean",
112112
controls: "boolean",

testing/web-platform/tests/html/dom/new-harness.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ ReflectionHarness.test = function(fun, description) {
88

99
ReflectionHarness.assertEquals = assert_equals;
1010

11+
ReflectionHarness.assertInArray = assert_in_array;
12+
1113
ReflectionHarness.assertThrows = assert_throws_dom;

testing/web-platform/tests/html/dom/original-harness.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ ReflectionHarness.assertEquals = function(expected, actual, description) {
130130
}
131131
}
132132

133+
/**
134+
* If answer.includes(question), output a success, else report a failure with the
135+
* given description. Currently success and failure both increment counters,
136+
* and failures output a message to a <ul>. Which <ul> is decided by the type
137+
* parameter -- different attribute types are separated for readability.
138+
*
139+
* @public
140+
*/
141+
ReflectionHarness.assertInArray = function(expected, actual, description) {
142+
if (actual.includes(expected)) {
143+
this.increment(this.passed);
144+
} else {
145+
this.increment(this.failed);
146+
this.reportFailure(this.currentTestDescription +
147+
(description ? " followed by " + description : "") +
148+
' (expected one of ' + this.stringRep(actual) + ', got ' +
149+
this.stringRep(expected) + ')');
150+
}
151+
}
152+
133153
/**
134154
* If calling fn causes a DOMException of the type given by the string
135155
* exceptionName (e.g., "IndexSizeError"), output a success. Otherwise, report

testing/web-platform/tests/html/dom/reflection.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ var maxUnsigned = 4294967295;
186186
*
187187
* "jsType": What typeof idlObj[idlName] is supposed to be.
188188
* "defaultVal": The default value to be returned if the attribute is not
189-
* present and no default is specifically set for this attribute.
189+
* present and no default is specifically set for this attribute. If
190+
* it is an array then any value in the array is acceptable.
190191
* "domTests": What values to test with setAttribute().
191192
* "domExpected": What values to expect with IDL get after setAttribute().
192193
* Defaults to the same as domTests.
@@ -761,7 +762,12 @@ ReflectionTests.reflects = function(data, idlName, idlObj, domName, domObj) {
761762
}
762763
if (!data.customGetter && (defaultVal !== null || data.isNullable)) {
763764
ReflectionHarness.test(function() {
765+
// Tests can pass an array of acceptable values
766+
if (Array.isArray(defaultVal)) {
767+
ReflectionHarness.assertInArray(idlObj[idlName], defaultVal);
768+
} else {
764769
ReflectionHarness.assertEquals(idlObj[idlName], defaultVal);
770+
}
765771
}, "IDL get with DOM attribute unset");
766772
}
767773

@@ -947,8 +953,14 @@ ReflectionTests.reflects = function(data, idlName, idlObj, domName, domObj) {
947953
domObj.setAttribute(domName, domTests[i]);
948954
ReflectionHarness.assertEquals(domObj.getAttribute(domName),
949955
String(domTests[i]), "getAttribute()");
950-
ReflectionHarness.assertEquals(idlObj[idlName], domExpected[i],
951-
"IDL get");
956+
// Tests can pass an array of acceptable values
957+
if (Array.isArray(domExpected[i])) {
958+
ReflectionHarness.assertInArray(idlObj[idlName], domExpected[i],
959+
"IDL get");
960+
} else {
961+
ReflectionHarness.assertEquals(idlObj[idlName], domExpected[i],
962+
"IDL get");
963+
}
952964
}, "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]));
953965
}
954966

@@ -986,7 +998,14 @@ ReflectionTests.reflects = function(data, idlName, idlObj, domName, domObj) {
986998
ReflectionHarness.assertEquals(domObj.getAttribute(domName), expected,
987999
"getAttribute()");
9881000
}
989-
if (idlIdlExpected[i] !== null || data.isNullable) {
1001+
// Ensure enumerated attributes never reflect in their non-canonical representations
1002+
if (data.type == "enum" && data.nonCanon[idlObj[idlName]]) {
1003+
ReflectionHarness.assertEquals(idlObj[idlName], data.nonCanon[idlObj[idlName]], "IDL get canonical");
1004+
}
1005+
// Tests can pass an array of acceptable values
1006+
if (Array.isArray(idlIdlExpected[i])) {
1007+
ReflectionHarness.assertInArray(idlObj[idlName], idlIdlExpected[i], "IDL get");
1008+
} else if (idlIdlExpected[i] !== null || data.isNullable) {
9901009
ReflectionHarness.assertEquals(idlObj[idlName], idlIdlExpected[i], "IDL get");
9911010
}
9921011
}

0 commit comments

Comments
 (0)