diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 4a8fc430b68..e528e01a434 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -789,9 +789,10 @@ nsOuterWindowProxy::defineProperty(JSContext* cx, int32_t index = GetArrayIndexFromId(cx, id); if (IsArrayIndex(index)) { // Spec says to Reject whether this is a supported index or not, - // since we have no indexed setter or indexed creator. It is up - // to the caller to decide whether to throw a TypeError. - return result.failCantDefineWindowElement(); + // since we have no indexed setter or indexed creator. That means + // throwing in strict mode (FIXME: Bug 828137), doing nothing in + // non-strict mode. + return result.succeed(); } // For now, allow chrome code to define non-configurable properties diff --git a/dom/base/test/test_window_indexing.html b/dom/base/test/test_window_indexing.html index 4eb418f7472..b560db16be1 100644 --- a/dom/base/test/test_window_indexing.html +++ b/dom/base/test/test_window_indexing.html @@ -50,22 +50,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=823228 is(window[1], undefined, "We should not have a value here"); // defineProperty() hook test - function throws(errorCtor, f) { - try { - f(); - } catch (exc) { - if (!(exc instanceof errorCtor)) - throw exc; - return; - } - throw new Error("expected " + errCtor.name + ", no exception thrown: " + f); - } - x.parentNode.appendChild(y); - throws(TypeError, function () { - Object.defineProperty(window, "1", { value: "FAIL2", configurable: true, - writable: true }); - }); + Object.defineProperty(window, "1", { value: "FAIL2", configurable: true, + writable: true }) y.parentNode.removeChild(y); ok(!("1" in window), "We no longer have two subframes, again"); is(window[1], undefined, "We should not have a value here either"); @@ -89,10 +76,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=823228 is(window[1], undefined, "And now we should be back to no [1] property"); // And more defineProperty() - throws(TypeError, function () { - Object.defineProperty(window, "1", { value: "FAIL2", configurable: true, - writable: true }); - }); + Object.defineProperty(window, "1", { value: "FAIL2", configurable: true, + writable: true }) ok(!("1" in window), "Defining indexed properties really just shouldn't work"); is(window[1], undefined, "Defining past end of list should not work"); diff --git a/js/public/Class.h b/js/public/Class.h index 7595572929e..57a5766cb2a 100644 --- a/js/public/Class.h +++ b/js/public/Class.h @@ -121,10 +121,8 @@ class ObjectOpResult JS_PUBLIC_API(bool) failCantRedefineProp(); JS_PUBLIC_API(bool) failReadOnly(); JS_PUBLIC_API(bool) failGetterOnly(); - JS_PUBLIC_API(bool) failCantDelete(); - JS_PUBLIC_API(bool) failCantSetInterposed(); - JS_PUBLIC_API(bool) failCantDefineWindowElement(); + JS_PUBLIC_API(bool) failCantDelete(); JS_PUBLIC_API(bool) failCantDeleteWindowElement(); JS_PUBLIC_API(bool) failCantDeleteWindowNamedProperty(); JS_PUBLIC_API(bool) failCantPreventExtensions(); diff --git a/js/src/js.msg b/js/src/js.msg index 15d80811ce0..14a89e2da0f 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -478,7 +478,6 @@ MSG_DEF(JSMSG_ATOMICS_WAIT_NOT_ALLOWED, 0, JSEXN_ERR, "waiting is not allowed o // XPConnect wrappers and DOM bindings MSG_DEF(JSMSG_CANT_SET_INTERPOSED, 1, JSEXN_TYPEERR, "unable to set interposed data property '{0}'") -MSG_DEF(JSMSG_CANT_DEFINE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't define elements on a Window object") MSG_DEF(JSMSG_CANT_DELETE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't delete elements from a Window object") MSG_DEF(JSMSG_CANT_DELETE_WINDOW_NAMED_PROPERTY, 1, JSEXN_TYPEERR, "can't delete property {0} from window's named properties object") MSG_DEF(JSMSG_CANT_PREVENT_EXTENSIONS, 0, JSEXN_TYPEERR, "can't prevent extensions on this proxy object") diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index f8dea41563d..02cd4552470 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -197,12 +197,6 @@ JS::ObjectOpResult::failGetterOnly() return fail(JSMSG_GETTER_ONLY); } -JS_PUBLIC_API(bool) -JS::ObjectOpResult::failCantDelete() -{ - return fail(JSMSG_CANT_DELETE); -} - JS_PUBLIC_API(bool) JS::ObjectOpResult::failCantSetInterposed() { @@ -210,9 +204,9 @@ JS::ObjectOpResult::failCantSetInterposed() } JS_PUBLIC_API(bool) -JS::ObjectOpResult::failCantDefineWindowElement() +JS::ObjectOpResult::failCantDelete() { - return fail(JSMSG_CANT_DEFINE_WINDOW_ELEMENT); + return fail(JSMSG_CANT_DELETE); } JS_PUBLIC_API(bool) diff --git a/js/src/tests/js1_5/extensions/regress-385134.js b/js/src/tests/js1_5/extensions/regress-385134.js index 041f4d6e7a4..603ddb30a58 100644 --- a/js/src/tests/js1_5/extensions/regress-385134.js +++ b/js/src/tests/js1_5/extensions/regress-385134.js @@ -24,11 +24,7 @@ function test() typeof this.watch != 'undefined' && typeof uneval != 'undefined') { - try { - this.__defineSetter__(0, function(){}); - } catch (exc) { - // In the browser, this fails. Ignore the error. - } + this.__defineSetter__(0, function(){}); this.watch(0, function(){}); uneval(this); } diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index 6a03b7ed5cd..742e6319fa6 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -29,11 +29,11 @@ namespace js { * * https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode */ -static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 248; +static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 247; static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND); -static_assert(JSErr_Limit == 387, +static_assert(JSErr_Limit == 386, "GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or " "removed MSG_DEFs from js.msg, you should increment " "XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "