Bug 1010577 - Shim window.controllers (with a warning) in RELEASE_BUILDs. r=bz

This commit is contained in:
Bobby Holley 2014-05-19 13:08:08 -07:00
parent 7683ced05a
commit 715f351f2b
3 changed files with 32 additions and 0 deletions

View File

@ -39,3 +39,4 @@ DEPRECATED_OPERATION(Window_Content)
DEPRECATED_OPERATION(SyncXMLHttpRequest)
DEPRECATED_OPERATION(DataContainerEvent)
DEPRECATED_OPERATION(SendAsBinary)
DEPRECATED_OPERATION(Window_Controllers)

View File

@ -2695,6 +2695,18 @@ nsWindowSH::NameStructEnabled(JSContext* aCx, nsGlobalWindow *aWin,
OldBindingConstructorEnabled(nameStruct, aWin, aCx);
}
#ifdef RELEASE_BUILD
#define USE_CONTROLLERS_SHIM
#endif
#ifdef USE_CONTROLLERS_SHIM
static const JSClass ControllersShimClass = {
"XULControllers", 0,
JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, nullptr
};
#endif
// static
nsresult
nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
@ -2705,6 +2717,23 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
return LookupComponentsShim(cx, obj, aWin, desc);
}
#ifdef USE_CONTROLLERS_SHIM
if (id == XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_CONTROLLERS) &&
!xpc::IsXrayWrapper(obj) &&
!nsContentUtils::IsSystemPrincipal(aWin->GetPrincipal()))
{
if (aWin->GetDoc()) {
aWin->GetDoc()->WarnOnceAbout(nsIDocument::eWindow_Controllers);
}
JS::Rooted<JSObject*> shim(cx, JS_NewObject(cx, &ControllersShimClass, JS::NullPtr(), obj));
if (NS_WARN_IF(!shim)) {
return NS_ERROR_OUT_OF_MEMORY;
}
FillPropertyDescriptor(desc, obj, JS::ObjectValue(*shim), /* readOnly = */ false);
return NS_OK;
}
#endif
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);

View File

@ -147,3 +147,5 @@ ImplicitMetaViewportTagFallback=No meta-viewport tag found. Please explicitly sp
DataContainerEventWarning=Use of DataContainerEvent is deprecated. Use CustomEvent instead.
# LOCALIZATION NOTE: Do not translate "sendAsBinary" or "send(Blob data)"
SendAsBinaryWarning=The non-standard sendAsBinary method is deprecated and will soon be removed. Use the standard send(Blob data) method instead.
# LOCALIZATION NOTE: Do not translate "window.controllers"
Window_ControllersWarning=window.controllers is deprecated. Do not use it for UA detection.