diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 5decfbdef895..795e88dd779d 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -4200,6 +4200,14 @@ GetPropertyHelperInline(JSContext *cx, if (!script || script->warnedAboutUndefinedProp()) return true; + /* + * Don't warn in self-hosted code (where the further presence of + * JS::ContextOptions::werror() would result in impossible-to-avoid + * errors to entirely-innocent client code). + */ + if (script->selfHosted()) + return true; + /* We may just be checking if that object has an iterator. */ if (JSID_IS_ATOM(id, cx->names().iteratorIntrinsic)) return true; diff --git a/js/src/tests/Intl/extensions/browser.js b/js/src/tests/Intl/extensions/browser.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/js/src/tests/Intl/extensions/options-value-emulates-undefined.js b/js/src/tests/Intl/extensions/options-value-emulates-undefined.js new file mode 100644 index 000000000000..e7af6a4860de --- /dev/null +++ b/js/src/tests/Intl/extensions/options-value-emulates-undefined.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!xulRuntime.shell) +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 843004; +var summary = + "Use of an object that emulates |undefined| as the sole option must " + + "preclude imputing default values"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var opt = objectEmulatingUndefined(); +opt.toString = function() { return "long"; }; + +var str = new Date(2013, 12 - 1, 14).toLocaleString("en-US", { weekday: opt }); + +// Because "weekday" was present and not undefined (stringifying to "long"), +// this must be a string like "Saturday" (in this implementation, that is). +assertEq(str, "Saturday"); + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/Intl/extensions/shell.js b/js/src/tests/Intl/extensions/shell.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/js/src/tests/js1_8_5/extensions/selfhosted-detecting-strict.js b/js/src/tests/js1_8_5/extensions/selfhosted-detecting-strict.js new file mode 100644 index 000000000000..cb4c026eaa83 --- /dev/null +++ b/js/src/tests/js1_8_5/extensions/selfhosted-detecting-strict.js @@ -0,0 +1,27 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 843004; +var summary = + "Don't emit a strict warning for the undefined-property detection pattern in self-hosted code"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +options("strict", "werror"); + +// Don't strict-warn (and throw, because of strict) when self-hosted code uses +// detecting-safe undefined-property accesses (|options.weekday !== undefined| +// and similar in ToDateTimeOptions, to be precise). +new Date().toLocaleString("en-US", {}); + +// If we get here, the test passed. + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete");