author | Boris Zbarsky <bzbarsky@mit.edu> |
Wed, 29 Oct 2014 15:06:31 -0400 | |
changeset 213005 | d0563150294baa25bb783f8bfd628c5985ee5416 |
parent 213004 | 4b4c7462ec89a4f090f950f7cef82eba6740829f |
child 213006 | 66860992cd5ea5e12dc41ec39101de2cca4b7737 |
push id | 27738 |
push user | cbook@mozilla.com |
push date | Thu, 30 Oct 2014 13:46:07 +0000 |
treeherder | mozilla-central@1aa1b23d799e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bholley |
bugs | 1088002 |
milestone | 36.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -104,18 +104,23 @@ static bool gIgnoreReportedErrors = fals static bool gQuitting = false; static bool reportWarnings = true; static bool compileOnly = false; static JSPrincipals *gJSPrincipals = nullptr; static nsAutoString *gWorkingDirectory = nullptr; static bool -GetLocationProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp) +GetLocationProperty(JSContext *cx, unsigned argc, Value *vp) { + CallArgs args = CallArgsFromVp(argc, vp); + if (!args.thisv().isObject()) { + JS_ReportError(cx, "Unexpected this value for GetLocationProperty"); + return false; + } #if !defined(XP_WIN) && !defined(XP_UNIX) //XXX: your platform should really implement this return false; #else JS::AutoFilename filename; if (JS::DescribeScriptedCaller(cx, &filename) && filename.get()) { nsresult rv; nsCOMPtr<nsIXPConnect> xpc = @@ -166,23 +171,23 @@ GetLocationProperty(JSContext *cx, Handl if (location) { nsCOMPtr<nsIXPConnectJSObjectHolder> locationHolder; bool symlink; // don't normalize symlinks, because that's kind of confusing if (NS_SUCCEEDED(location->IsSymlink(&symlink)) && !symlink) location->Normalize(); - rv = xpc->WrapNative(cx, obj, location, + rv = xpc->WrapNative(cx, &args.thisv().toObject(), location, NS_GET_IID(nsIFile), getter_AddRefs(locationHolder)); if (NS_SUCCEEDED(rv) && locationHolder->GetJSObject()) { - vp.set(OBJECT_TO_JSVAL(locationHolder->GetJSObject())); + args.rval().setObject(*locationHolder->GetJSObject()); } } } return true; #endif } @@ -1492,18 +1497,20 @@ XRE_XPCShellMain(int argc, char **argv, } JS_SetPrivate(envobj, envp); nsAutoString workingDirectory; if (GetCurrentWorkingDirectory(workingDirectory)) gWorkingDirectory = &workingDirectory; - JS_DefineProperty(cx, glob, "__LOCATION__", JS::UndefinedHandleValue, 0, - GetLocationProperty, nullptr); + JS_DefineProperty(cx, glob, "__LOCATION__", JS::UndefinedHandleValue, + JSPROP_NATIVE_ACCESSORS | JSPROP_SHARED, + JS_CAST_NATIVE_TO(GetLocationProperty, JSPropertyOp), + nullptr); // We are almost certainly going to run script here, so we need an // AutoEntryScript. This is Gecko-specific and not in any spec. dom::AutoEntryScript aes(backstagePass); result = ProcessArgs(aes.cx(), glob, argv, argc, &dirprovider); JS_DropPrincipals(rt, gJSPrincipals); JS_SetAllNonReservedSlotsToUndefined(aes.cx(), glob);