Skip to content

Commit 9eae7a5

Browse files
committed
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 UltraBlame original commit: 7db870643f1aa46af646cf0424d98cd4b6b23407
1 parent 9f7cea0 commit 9eae7a5

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var embeddedElements = {
8989
src: "url",
9090
crossOrigin: {type: "enum", keywords: ["anonymous", "use-credentials"], nonCanon:{"": "anonymous"}, isNullable: true, defaultVal: null, invalidVal: "anonymous"},
9191

92-
preload: {type: "enum", keywords: ["none", "metadata", "auto"], nonCanon: {"": "auto"}, defaultVal: null},
92+
preload: {type: "enum", keywords: ["none", "metadata", "auto"], nonCanon: {"": "auto"}, defaultVal: ["none", "metadata", "auto"]},
9393
autoplay: "boolean",
9494
loop: "boolean",
9595
controls: "boolean",
@@ -106,7 +106,7 @@ var embeddedElements = {
106106
src: "url",
107107
crossOrigin: {type: "enum", keywords: ["anonymous", "use-credentials"], nonCanon:{"": "anonymous"}, isNullable: true, defaultVal: null, invalidVal: "anonymous"},
108108

109-
preload: {type: "enum", keywords: ["none", "metadata", "auto"], nonCanon: {"": "auto"}, defaultVal: null},
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
@@ -137,6 +137,26 @@ ReflectionHarness.assertEquals = function(expected, actual, description) {
137137

138138

139139

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+
153+
154+
155+
156+
157+
158+
159+
140160
ReflectionHarness.assertThrows = function(exceptionName, fn) {
141161
try {
142162
fn();

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ var maxUnsigned = 4294967295;
213213

214214

215215

216+
216217

217218

218219
ReflectionTests.typeMap = {
@@ -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+
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+
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+
1002+
if (data.type == "enum" && data.nonCanon[idlObj[idlName]]) {
1003+
ReflectionHarness.assertEquals(idlObj[idlName], data.nonCanon[idlObj[idlName]], "IDL get canonical");
1004+
}
1005+
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)