mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-02 20:20:00 +00:00
Bug 865729 - Use XPConnect directly in C++ unit tests. r=gabor
This commit is contained in:
parent
dde0ee15d3
commit
f3b8f66f21
@ -21,7 +21,7 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsITelemetry.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
#include "prio.h"
|
||||
|
||||
@ -505,10 +505,9 @@ int main(int argc, char** argv)
|
||||
// using the cx here without triggering a cx stack assert, so just do that
|
||||
// for now. Eventually, the whole notion of pushing and popping will just go
|
||||
// away.
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (stack)
|
||||
cx = stack->GetSafeJSContext();
|
||||
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
|
||||
if (xpc)
|
||||
cx = xpc->GetSafeJSContext();
|
||||
|
||||
bool use_js = !!cx;
|
||||
JSAutoRequest req(cx);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "nsISettingsService.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@ -153,13 +153,8 @@ TestSettingsObserver::Observe(nsISupports *aSubject,
|
||||
}
|
||||
|
||||
// Get the safe JS context.
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
CHECK_MSG(false, "Failed to get JSContextStack");
|
||||
return NS_OK;
|
||||
}
|
||||
JSContext *cx = stack->GetSafeJSContext();
|
||||
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
|
||||
JSContext *cx = xpc->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
CHECK_MSG(false, "Failed to GetSafeJSContext");
|
||||
return NS_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user