summaryrefslogtreecommitdiffstats
path: root/js/xpconnect
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-27 15:57:18 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-27 15:57:18 +0200
commitd990d8ab2cade6c928e8bbe56ae038d020cef599 (patch)
treec7561ae0f303cb0d4a7a7507178531b4852e4dea /js/xpconnect
parent0c36b27511c1fbca594f0426c493ef601fda3e4c (diff)
parent8d5ec757ece850fb7ad5c712868f305636e41177 (diff)
downloadUXP-d990d8ab2cade6c928e8bbe56ae038d020cef599.tar
UXP-d990d8ab2cade6c928e8bbe56ae038d020cef599.tar.gz
UXP-d990d8ab2cade6c928e8bbe56ae038d020cef599.tar.lz
UXP-d990d8ab2cade6c928e8bbe56ae038d020cef599.tar.xz
UXP-d990d8ab2cade6c928e8bbe56ae038d020cef599.zip
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into js_array_values_1
Diffstat (limited to 'js/xpconnect')
-rw-r--r--js/xpconnect/loader/mozJSComponentLoader.cpp8
-rw-r--r--js/xpconnect/loader/mozJSSubScriptLoader.cpp4
-rw-r--r--js/xpconnect/tests/chrome/test_xrayToJS.xul14
-rw-r--r--js/xpconnect/tests/unit/test_xray_regexp.js9
-rw-r--r--js/xpconnect/tests/unit/xpcshell.ini1
-rw-r--r--js/xpconnect/wrappers/XrayWrapper.cpp20
6 files changed, 17 insertions, 39 deletions
diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp
index 95c214867..85591bc8a 100644
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -306,14 +306,6 @@ mozJSComponentLoader::ReallyInit()
mReuseLoaderGlobal = Preferences::GetBool("jsloader.reuseGlobal");
- // XXXkhuey B2G child processes have some sort of preferences race that
- // results in getting the wrong value.
- // But we don't want that on Firefox Mulet as it break most Firefox JSMs...
- // Also disable on debug builds to break js components that rely on this.
-#if defined(MOZ_B2G) && !defined(MOZ_MULET) && !defined(DEBUG)
- mReuseLoaderGlobal = true;
-#endif
-
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
if (!secman)
diff --git a/js/xpconnect/loader/mozJSSubScriptLoader.cpp b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
index 824e9ab9e..9c8908ea4 100644
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -130,7 +130,9 @@ PrepareScript(nsIURI* uri,
MutableHandleFunction function)
{
JS::CompileOptions options(cx);
- options.setFileAndLine(uriStr, 1)
+ // Use line 0 to make the function body starts from line 1 when
+ // |reuseGlobal == true|.
+ options.setFileAndLine(uriStr, reuseGlobal ? 0 : 1)
.setVersion(JSVERSION_LATEST);
if (!charset.IsVoid()) {
char16_t* scriptBuf = nullptr;
diff --git a/js/xpconnect/tests/chrome/test_xrayToJS.xul b/js/xpconnect/tests/chrome/test_xrayToJS.xul
index 25f882f23..ed67a34fe 100644
--- a/js/xpconnect/tests/chrome/test_xrayToJS.xul
+++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul
@@ -220,11 +220,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
// There is no TypedArray constructor, looks like.
is(window.TypedArray, undefined, "If this ever changes, add to this test!");
for (var c of errorObjectClasses) {
- gPrototypeProperties[c] = ["constructor", "name",
- // We don't actually resolve these empty data properties
- // onto the Xray prototypes, but we list them here to make
- // the test happy.
- "lineNumber", "columnNumber", "fileName", "message", "stack"];
+ gPrototypeProperties[c] = ["constructor", "name", "message", "stack"];
gConstructorProperties[c] = constructorProps([]);
}
// toString and toSource only live on the parent proto (Error.prototype).
@@ -239,8 +235,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
gPrototypeProperties['RegExp'] =
["constructor", "toSource", "toString", "compile", "exec", "test",
Symbol.match, Symbol.replace, Symbol.search, Symbol.split,
- "flags", "global", "ignoreCase", "multiline", "source", "sticky", "unicode",
- "lastIndex"];
+ "flags", "global", "ignoreCase", "multiline", "source", "sticky", "unicode"];
gConstructorProperties['RegExp'] =
constructorProps(["input", "lastMatch", "lastParen",
"leftContext", "rightContext", "$1", "$2", "$3", "$4",
@@ -791,8 +786,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
// We only invoke testXray with Error, because that function isn't set up
// to deal with dependent classes and fixing it up is more trouble than
// it's worth.
- testXray('Error', new iwin.Error('some error message'), new iwin.Error(),
- ['fileName', 'lineNumber', 'columnNumber', 'message']);
+ testXray('Error', new iwin.Error('some error message'), new iwin.Error());
// Make sure that the dependent classes have their prototypes set up correctly.
for (let c of errorObjectClasses.filter(x => x != "Error")) {
@@ -806,7 +800,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
e.wrappedJSObject[name] = goodReplacement;
is(e[name], goodReplacement, name + " property ok after replacement: " + goodReplacement);
e.wrappedJSObject[name] = faultyReplacement;
- is(e[name], undefined, name + " property censored after suspicious replacement");
+ is(e[name], name == 'message' ? "" : undefined, name + " property skipped after suspicious replacement");
}
testProperty('message', x => x == 'some message', 'some other message', 42);
testProperty('fileName', x => x == '', 'otherFilename.html', new iwin.Object());
diff --git a/js/xpconnect/tests/unit/test_xray_regexp.js b/js/xpconnect/tests/unit/test_xray_regexp.js
new file mode 100644
index 000000000..4baffd63e
--- /dev/null
+++ b/js/xpconnect/tests/unit/test_xray_regexp.js
@@ -0,0 +1,9 @@
+const Cu = Components.utils;
+
+function run_test() {
+ var sandbox = Cu.Sandbox('http://www.example.com');
+ var regexp = Cu.evalInSandbox("/test/i", sandbox);
+ equal(RegExp.prototype.toString.call(regexp), "/test/i");
+ var prototype = Cu.evalInSandbox("RegExp.prototype", sandbox);
+ equal(typeof prototype.lastIndex, "undefined");
+}
diff --git a/js/xpconnect/tests/unit/xpcshell.ini b/js/xpconnect/tests/unit/xpcshell.ini
index 99d44b975..12648d3ec 100644
--- a/js/xpconnect/tests/unit/xpcshell.ini
+++ b/js/xpconnect/tests/unit/xpcshell.ini
@@ -133,5 +133,6 @@ head = head_watchdog.js
[test_xrayed_iterator.js]
[test_xray_SavedFrame.js]
[test_xray_SavedFrame-02.js]
+[test_xray_regexp.js]
[test_resolve_dead_promise.js]
[test_asyncLoadSubScriptError.js]
diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp
index 5e537692d..48a9fdc68 100644
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -636,18 +636,6 @@ JSXrayTraits::resolveOwnProperty(JSContext* cx, const Wrapper& jsWrapper,
return true;
}
- // Handle the 'name' property for error prototypes.
- if (IsErrorObjectKey(key) && id == GetJSIDByIndex(cx, XPCJSContext::IDX_NAME)) {
- RootedId className(cx);
- ProtoKeyToId(cx, key, &className);
- FillPropertyDescriptor(desc, wrapper, 0, UndefinedValue());
- return JS_IdToValue(cx, className, desc.value());
- }
-
- // Handle the 'lastIndex' property for RegExp prototypes.
- if (key == JSProto_RegExp && id == GetJSIDByIndex(cx, XPCJSContext::IDX_LASTINDEX))
- return getOwnPropertyFromWrapperIfSafe(cx, wrapper, id, desc);
-
// Grab the JSClass. We require all Xrayable classes to have a ClassSpec.
const js::Class* clasp = js::GetObjectClass(target);
MOZ_ASSERT(clasp->specDefined());
@@ -889,14 +877,6 @@ JSXrayTraits::enumerateNames(JSContext* cx, HandleObject wrapper, unsigned flags
if (!props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_CONSTRUCTOR)))
return false;
- // For Error protoypes, add the 'name' property.
- if (IsErrorObjectKey(key) && !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_NAME)))
- return false;
-
- // For RegExp protoypes, add the 'lastIndex' property.
- if (key == JSProto_RegExp && !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_LASTINDEX)))
- return false;
-
// Grab the JSClass. We require all Xrayable classes to have a ClassSpec.
const js::Class* clasp = js::GetObjectClass(target);
MOZ_ASSERT(clasp->specDefined());