Backed out changeset 2a70c56c2469 (bug 897913)

This commit is contained in:
Ed Morley 2013-08-07 15:50:10 -07:00
parent 6318f92344
commit aaa9bef673
4 changed files with 9 additions and 38 deletions

View File

@ -13,9 +13,4 @@ LIBRARY_NAME = dompromise_s
LIBXUL_LIBRARY = 1
FAIL_ON_WARNINGS := 1
LOCAL_INCLUDES += \
-I$(topsrcdir)/dom/workers \
-I$(topsrcdir)/dom/base \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -11,8 +11,6 @@
#include "PromiseCallback.h"
#include "nsContentUtils.h"
#include "nsPIDOMWindow.h"
#include "WorkerPrivate.h"
#include "nsJSPrincipals.h"
namespace mozilla {
namespace dom {
@ -112,26 +110,6 @@ Promise::PrefEnabled()
return Preferences::GetBool("dom.promise.enabled", false);
}
/* static */ bool
Promise::EnabledForScope(JSContext* aCx, JSObject* /* unused */)
{
// Enable if the pref is enabled or if we're chrome or if we're a
// certified app.
if (PrefEnabled()) {
return true;
}
// Note that we have no concept of a certified app in workers.
// XXXbz well, why not?
if (!NS_IsMainThread()) {
return workers::GetWorkerPrivateFromContext(aCx)->IsChromeWorker();
}
nsIPrincipal* prin = nsContentUtils::GetSubjectPrincipal();
return nsContentUtils::IsSystemPrincipal(prin) ||
prin->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
}
static void
EnterCompartment(Maybe<JSAutoCompartment>& aAc, JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aValue)
@ -147,6 +125,8 @@ EnterCompartment(Maybe<JSAutoCompartment>& aAc, JSContext* aCx,
Promise::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
PromiseInit& aInit, ErrorResult& aRv)
{
MOZ_ASSERT(PrefEnabled());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);
@ -175,6 +155,8 @@ Promise::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
{
MOZ_ASSERT(PrefEnabled());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);
@ -192,6 +174,8 @@ Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
Promise::Reject(const GlobalObject& aGlobal, JSContext* aCx,
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
{
MOZ_ASSERT(PrefEnabled());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);

View File

@ -41,7 +41,6 @@ public:
~Promise();
static bool PrefEnabled();
static bool EnabledForScope(JSContext* aCx, JSObject* /* unused */);
// WebIDL

View File

@ -7,7 +7,6 @@
* http://dom.spec.whatwg.org/#promises
*/
[Func="mozilla::dom::Promise::EnabledForScope"]
interface PromiseResolver {
// TODO bug 875289 - void fulfill(optional any value);
void resolve(optional any value);
@ -17,18 +16,12 @@ interface PromiseResolver {
callback PromiseInit = void (PromiseResolver resolver);
callback AnyCallback = any (optional any value);
[Func="mozilla::dom::Promise::EnabledForScope", Constructor(PromiseInit init)]
[PrefControlled, Constructor(PromiseInit init)]
interface Promise {
// TODO bug 875289 - static Promise fulfill(any value);
// Disable the static methods when the interface object is supposed to be
// disabled, just in case some code decides to walk over to .constructor from
// the proto of a promise object or someone screws up and manages to create a
// Promise object in this scope without having resolved the interface object
// first.
[Creator, Throws, Func="mozilla::dom::Promise::EnabledForScope"]
[Creator, Throws]
static Promise resolve(any value); // same as any(value)
[Creator, Throws, Func="mozilla::dom::Promise::EnabledForScope"]
[Creator, Throws]
static Promise reject(any value);
[Creator]