Skip to content

Commit 9a87824

Browse files
committed
Bug 1414292. Update to HTML spec changes for cross-origin object property enumerability. r=peterv
Updates to whatwg/html#3186 Includes the changes from web-platform-tests/wpt#8045 MozReview-Commit-ID: 5vEo1QGPufE UltraBlame original commit: 2a5a80d284b5ef958298cf515867ffbe420478c0
1 parent 5f11653 commit 9a87824

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

js/xpconnect/wrappers/FilteringWrapper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ CrossOriginXrayWrapper::getPropertyDescriptor(JSContext* cx,
225225

226226

227227

228-
desc.attributesRef() &= ~JSPROP_ENUMERATE;
228+
229+
if (!JSID_IS_INT(id)) {
230+
desc.attributesRef() &= ~JSPROP_ENUMERATE;
231+
}
229232
desc.attributesRef() &= ~JSPROP_PERMANENT;
230233
if (!desc.getter() && !desc.setter())
231234
desc.attributesRef() |= JSPROP_READONLY;

testing/web-platform/meta/html/browsers/origin/cross-origin-objects/cross-origin-objects.html.ini

Lines changed: 0 additions & 10 deletions
This file was deleted.

testing/web-platform/tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,20 @@
184184
}, "[[GetOwnProperty]] - Properties on cross-origin objects should be reported |own|");
185185

186186
function checkPropertyDescriptor(desc, propName, expectWritable) {
187-
var isSymbol = (typeof(propName) == "symbol");
187+
const isSymbol = typeof(propName) === "symbol";
188+
const isArrayIndexPropertyName = !isSymbol && !isNaN(parseInt(propName, 10));
188189
propName = String(propName);
189190
assert_true(isObject(desc), "property descriptor for " + propName + " should exist");
190191
assert_equals(desc.configurable, true, "property descriptor for " + propName + " should be configurable");
191-
if (isSymbol) {
192-
assert_equals(desc.enumerable, false, "symbol-property descriptor for " + propName + " should not be enumerable");
193-
assert_true("value" in desc,
194-
"property descriptor for " + propName + " should be a value descriptor");
195-
assert_equals(desc.value, undefined,
192+
if (!isArrayIndexPropertyName) {
193+
assert_equals(desc.enumerable, false, "property descriptor for " + propName + " should not be enumerable");
194+
if(isSymbol) {
195+
assert_true("value" in desc,
196+
"property descriptor for " + propName + " should be a value descriptor");
197+
assert_equals(desc.value, undefined,
196198
"symbol-named cross-origin visible prop " + propName +
197199
" should come back as undefined");
200+
}
198201
} else {
199202
assert_equals(desc.enumerable, true, "property descriptor for " + propName + " should be enumerable");
200203
}
@@ -265,16 +268,15 @@
265268
let i = 0;
266269
for (var prop in C) {
267270
i++;
268-
assert_true(whitelistedWindowPropNames.includes(prop), prop + " is not safelisted for a cross-origin Window");
271+
assert_true(whitelistedWindowIndices.includes(prop), prop + " is not safelisted for a cross-origin Window");
269272
}
270-
assert_equals(i, whitelistedWindowPropNames.length, "Enumerate all safelisted cross-origin Window properties");
273+
assert_equals(i, whitelistedWindowIndices.length, "Enumerate all enumerable safelisted cross-origin Window properties");
271274
i = 0;
272275
for (var prop in C.location) {
273276
i++;
274-
assert_true(whitelistedLocationPropNames.includes(prop), prop + " is not safelisted for a cross-origin Location");
275277
}
276-
assert_equals(i, whitelistedLocationPropNames.length, "Enumerate all safelisted cross-origin Location properties");
277-
}, "Can only enumerate safelisted properties");
278+
assert_equals(i, 0, "There's nothing to enumerate for cross-origin Location properties");
279+
}, "Can only enumerate safelisted enumerable properties");
278280

279281
/*
280282
* [[OwnPropertyKeys]]
@@ -285,14 +287,13 @@
285287
whitelistedWindowPropNames,
286288
"Object.getOwnPropertyNames() gives the right answer for cross-origin Window");
287289
assert_array_equals(Object.keys(C).sort(),
288-
whitelistedWindowPropNames,
290+
whitelistedWindowIndices,
289291
"Object.keys() gives the right answer for cross-origin Window");
290292
assert_array_equals(Object.getOwnPropertyNames(C.location).sort(),
291293
whitelistedLocationPropNames,
292294
"Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
293-
assert_array_equals(Object.keys(C.location).sort(),
294-
whitelistedLocationPropNames,
295-
"Object.keys() gives the right answer for cross-origin Location");
295+
assert_equals(Object.keys(C.location).length, 0,
296+
"Object.keys() gives the right answer for cross-origin Location");
296297
}, "[[OwnPropertyKeys]] should return all properties from cross-origin objects");
297298

298299
addTest(function() {

0 commit comments

Comments
 (0)