diff --git a/js/xpconnect/tests/mochitest/file_crossOriginObjects.html b/js/xpconnect/tests/mochitest/file_crossOriginObjects.html
deleted file mode 100644
index c3093ebdac3c3..0000000000000
--- a/js/xpconnect/tests/mochitest/file_crossOriginObjects.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/js/xpconnect/tests/mochitest/file_crossOriginObjects_documentDomain.html b/js/xpconnect/tests/mochitest/file_crossOriginObjects_documentDomain.html
deleted file mode 100644
index 1c0f05bd25f0d..0000000000000
--- a/js/xpconnect/tests/mochitest/file_crossOriginObjects_documentDomain.html
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/js/xpconnect/tests/mochitest/mochitest.ini b/js/xpconnect/tests/mochitest/mochitest.ini
index ffac4cc8f4a6a..94d71fdcdbc90 100644
--- a/js/xpconnect/tests/mochitest/mochitest.ini
+++ b/js/xpconnect/tests/mochitest/mochitest.ini
@@ -22,8 +22,6 @@ support-files =
file_bug799348.html
file_bug802557.html
file_bug860494.html
- file_crossOriginObjects.html
- file_crossOriginObjects_documentDomain.html
file_crosscompartment_weakmap.html
file_documentdomain.html
file_doublewrappedcompartments.html
@@ -94,7 +92,6 @@ support-files =
[test_bug1005806.html]
[test_bug1094930.html]
[test_bug1158558.html]
-[test_crossOriginObjects.html]
[test_crosscompartment_weakmap.html]
[test_frameWrapping.html]
# The JS test component we use below is only available in debug builds.
diff --git a/js/xpconnect/tests/mochitest/test_bug862380.html b/js/xpconnect/tests/mochitest/test_bug862380.html
index 0d3fb73293586..0f16117763202 100644
--- a/js/xpconnect/tests/mochitest/test_bug862380.html
+++ b/js/xpconnect/tests/mochitest/test_bug862380.html
@@ -13,16 +13,29 @@
/** Test for Bug 862380 **/
SimpleTest.waitForExplicitFinish();
function go() {
- checkNotEnumerable($('ifr').contentWindow);
- checkNotEnumerable($('ifr').contentWindow.location);
+ checkNotEnumerable($('ifr').contentWindow, true);
+ checkNotEnumerable($('ifr').contentWindow.location, false);
SimpleTest.finish();
}
- function checkNotEnumerable(obj) {
+function checkNotEnumerable(obj, isWindow) {
try {
- is(Object.keys(obj).length, 0, "Object.keys gives empty array");
+ const expectedWindow = ["0", "window", "location", "top", "close",
+ "focus", "blur", "postMessage", "self", "closed",
+ "frames", "length", "opener", "parent"];
+ const expectedLocation = ["replace", "href"];
+ const expected = isWindow ? expectedWindow : expectedLocation;
+ is(Object.keys(obj).length, expected.length,
+ "Object.keys gives right array length");
+ var actual = [];
for (var i in obj)
- ok(false, "Enumerated something: " + i);
+ actual.push(i);
+ is(actual.length, expected.length,
+ "Enumeration sees the right number of props");
+ actual.sort();
+ expected.sort();
+ for (var i = 0; i < actual.length; ++i)
+ is(actual[i], expected[i], "Arrays should be the same " + i);
} catch (e) {
ok(false, "threw: " + e);
}
diff --git a/js/xpconnect/tests/mochitest/test_crossOriginObjects.html b/js/xpconnect/tests/mochitest/test_crossOriginObjects.html
deleted file mode 100644
index e42228e5b93f0..0000000000000
--- a/js/xpconnect/tests/mochitest/test_crossOriginObjects.html
+++ /dev/null
@@ -1,335 +0,0 @@
-
-
-
-Cross-origin behavior of Window and Location
-
-
-
-
-
-
-
-
-
diff --git a/js/xpconnect/wrappers/FilteringWrapper.cpp b/js/xpconnect/wrappers/FilteringWrapper.cpp
index 1e986c734cde5..c35c3e896afc0 100644
--- a/js/xpconnect/wrappers/FilteringWrapper.cpp
+++ b/js/xpconnect/wrappers/FilteringWrapper.cpp
@@ -223,9 +223,8 @@ CrossOriginXrayWrapper::getPropertyDescriptor(JSContext* cx,
// All properties on cross-origin DOM objects are |own|.
desc.object().set(wrapper);
- // All properties on cross-origin DOM objects are non-enumerable and
- // "configurable". Any value attributes are read-only.
- desc.attributesRef() &= ~JSPROP_ENUMERATE;
+ // All properties on cross-origin DOM objects are "configurable". Any
+ // value attributes are read-only.
desc.attributesRef() &= ~JSPROP_PERMANENT;
if (!desc.getter() && !desc.setter())
desc.attributesRef() |= JSPROP_READONLY;
diff --git a/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html b/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html
index 442620b299e5e..06d96b11372db 100644
--- a/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html
+++ b/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html
@@ -187,14 +187,16 @@
var isSymbol = (typeof(propName) == "symbol");
propName = String(propName);
assert_true(isObject(desc), "property descriptor for " + propName + " should exist");
- assert_equals(desc.enumerable, false, "property descriptor for " + propName + " should be non-enumerable");
assert_equals(desc.configurable, true, "property descriptor for " + propName + " should be configurable");
if (isSymbol) {
+ assert_equals(desc.enumerable, false, "symbol-property descriptor for " + propName + " should not be enumerable");
assert_true("value" in desc,
"property descriptor for " + propName + " should be a value descriptor");
assert_equals(desc.value, undefined,
"symbol-named cross-origin visible prop " + propName +
" should come back as undefined");
+ } else {
+ assert_equals(desc.enumerable, true, "property descriptor for " + propName + " should be enumerable");
}
if ('value' in desc)
assert_equals(desc.writable, expectWritable, "property descriptor for " + propName + " should have writable: " + expectWritable);
@@ -256,15 +258,23 @@
}, "[[DefineOwnProperty]] Should throw for cross-origin objects");
/*
- * [[Enumerate]]
+ * EnumerateObjectProperties (backed by [[OwnPropertyKeys]])
*/
addTest(function() {
- for (var prop in C)
- assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
- for (var prop in C.location)
- assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location");
-}, "[[Enumerate]] should return an empty iterator");
+ let i = 0;
+ for (var prop in C) {
+ i++;
+ assert_true(whitelistedWindowPropNames.includes(prop), prop + " is not safelisted for a cross-origin Window");
+ }
+ assert_equals(i, whitelistedWindowPropNames.length, "Enumerate all safelisted cross-origin Window properties");
+ i = 0;
+ for (var prop in C.location) {
+ i++;
+ assert_true(whitelistedLocationPropNames.includes(prop), prop + " is not safelisted for a cross-origin Location");
+ }
+ assert_equals(i, whitelistedLocationPropNames.length, "Enumerate all safelisted cross-origin Location properties");
+}, "Can only enumerate safelisted properties");
/*
* [[OwnPropertyKeys]]
@@ -274,9 +284,15 @@
assert_array_equals(Object.getOwnPropertyNames(C).sort(),
whitelistedWindowPropNames,
"Object.getOwnPropertyNames() gives the right answer for cross-origin Window");
+ assert_array_equals(Object.keys(C).sort(),
+ whitelistedWindowPropNames,
+ "Object.keys() gives the right answer for cross-origin Window");
assert_array_equals(Object.getOwnPropertyNames(C.location).sort(),
whitelistedLocationPropNames,
"Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
+ assert_array_equals(Object.keys(C.location).sort(),
+ whitelistedLocationPropNames,
+ "Object.keys() gives the right answer for cross-origin Location");
}, "[[OwnPropertyKeys]] should return all properties from cross-origin objects");
addTest(function() {
diff --git a/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/frame.html b/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/frame.html
index 0a7769dc96718..341da6a978840 100644
--- a/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/frame.html
+++ b/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/frame.html
@@ -37,6 +37,6 @@
-
+