Bug 828137, part 2 - Make [[Set]] always fail on window elements. With this change, `window[0] = null;` is a TypeError in strict mode code. r=bz.

--HG--
extra : rebase_source : 10066af913c07b01a701b49915ca54e4131d702b
This commit is contained in:
Jason Orendorff 2015-02-11 11:47:39 -06:00
Родитель cd9a74e351
Коммит 93771d2a84
5 изменённых файлов: 13 добавлений и 16 удалений

Просмотреть файл

@ -915,9 +915,9 @@ nsOuterWindowProxy::set(JSContext *cx, JS::Handle<JSObject*> proxy,
{
int32_t index = GetArrayIndexFromId(cx, id);
if (IsArrayIndex(index)) {
// Reject (which means throw if and only if strict) the set.
// XXX See bug 828137.
return result.succeed();
// Reject the set. It's up to the caller to decide whether to throw a
// TypeError. If the caller is strict mode JS code, it'll throw.
return result.failReadOnly();
}
return js::Wrapper::set(cx, proxy, receiver, id, vp, result);

Просмотреть файл

@ -42,6 +42,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=823228
is(x.contentWindow, window[0], "First frame should have correct window");
is(y.contentWindow, window[1], "Second frame should have correct window");
// set() hook test
throws(TypeError, function () {
"use strict";
window[1] = "FAIL strict";
});
// set() hook test
window[1] = "FAIL";
is(window[1].name, "y", "Second frame is still y");
@ -71,6 +77,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=823228
is(window[1], undefined, "We should not have a value here either");
// More set() hook test
throws(TypeError, function () {
"use strict";
window[1] = "FAIL3 strict";
});
window[1] = "FAIL3";
ok(!("1" in window), "We shouldn't allow indexed expandos");
is(window[1], undefined, "We should not have a value for an indexed expando");

Просмотреть файл

@ -3,7 +3,6 @@
support-files =
[test_window-indexed-properties-strict.html.json]
[test_window-named-properties.html.json]
skip-if = true # bug 859075
[test_window-properties.html.json]

Просмотреть файл

@ -1,4 +0,0 @@
{
"Indexed properties of the window object (strict mode) 1": true,
"Indexed properties of the window object (strict mode) 2": true
}

Просмотреть файл

@ -1,8 +0,0 @@
[window-indexed-properties-strict.html]
type: testharness
[Indexed properties of the window object (strict mode) 1]
expected: FAIL
[Indexed properties of the window object (strict mode) 2]
expected: FAIL