mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changesets bacfdc83424a and 7d12b5d7446f (bug 984048) for crashes.
This commit is contained in:
parent
c14d2a19ab
commit
6b74ec8899
@ -27,7 +27,6 @@ namespace dom {
|
|||||||
|
|
||||||
class AnyCallback;
|
class AnyCallback;
|
||||||
class DOMError;
|
class DOMError;
|
||||||
class ErrorEvent;
|
|
||||||
class PromiseCallback;
|
class PromiseCallback;
|
||||||
class PromiseInit;
|
class PromiseInit;
|
||||||
class PromiseNativeHandler;
|
class PromiseNativeHandler;
|
||||||
@ -95,10 +94,6 @@ public:
|
|||||||
MOZ_ASSERT(NS_FAILED(aArg));
|
MOZ_ASSERT(NS_FAILED(aArg));
|
||||||
MaybeSomething(aArg, &Promise::MaybeReject);
|
MaybeSomething(aArg, &Promise::MaybeReject);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MaybeReject(ErrorEvent* aArg) {
|
|
||||||
MaybeSomething(aArg, &Promise::MaybeReject);
|
|
||||||
}
|
|
||||||
// DO NOT USE MaybeRejectBrokenly with in new code. Promises should be
|
// DO NOT USE MaybeRejectBrokenly with in new code. Promises should be
|
||||||
// rejected with Error instances.
|
// rejected with Error instances.
|
||||||
// Note: MaybeRejectBrokenly is a template so we can use it with DOMError
|
// Note: MaybeRejectBrokenly is a template so we can use it with DOMError
|
||||||
|
@ -278,8 +278,8 @@ WrapperPromiseCallback::Call(JSContext* aCx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JS::Value> typeError(aCx);
|
JS::Rooted<JS::Value> typeError(aCx);
|
||||||
if (!JS::CreateError(aCx, JSEXN_TYPEERR, stack, fn, lineNumber, 0,
|
if (!JS::CreateTypeError(aCx, stack, fn, lineNumber, 0,
|
||||||
nullptr, message, &typeError)) {
|
nullptr, message, &typeError)) {
|
||||||
// Out of memory. Promise will stay unresolved.
|
// Out of memory. Promise will stay unresolved.
|
||||||
JS_ClearPendingException(aCx);
|
JS_ClearPendingException(aCx);
|
||||||
return;
|
return;
|
||||||
|
@ -2175,33 +2175,6 @@ RuntimeService::CreateServiceWorker(const GlobalObject& aGlobal,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
RuntimeService::CreateServiceWorkerFromLoadInfo(JSContext* aCx,
|
|
||||||
WorkerPrivate::LoadInfo aLoadInfo,
|
|
||||||
const nsAString& aScriptURL,
|
|
||||||
const nsACString& aScope,
|
|
||||||
ServiceWorker** aServiceWorker)
|
|
||||||
{
|
|
||||||
|
|
||||||
nsRefPtr<SharedWorker> sharedWorker;
|
|
||||||
nsresult rv = CreateSharedWorkerFromLoadInfo(aCx, aLoadInfo, aScriptURL, aScope,
|
|
||||||
WorkerTypeService,
|
|
||||||
getter_AddRefs(sharedWorker));
|
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRefPtr<ServiceWorker> serviceWorker =
|
|
||||||
new ServiceWorker(nullptr, sharedWorker);
|
|
||||||
|
|
||||||
serviceWorker->mURL = aScriptURL;
|
|
||||||
serviceWorker->mScope = NS_ConvertUTF8toUTF16(aScope);
|
|
||||||
|
|
||||||
serviceWorker.forget(aServiceWorker);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
RuntimeService::CreateSharedWorkerInternal(const GlobalObject& aGlobal,
|
RuntimeService::CreateSharedWorkerInternal(const GlobalObject& aGlobal,
|
||||||
const nsAString& aScriptURL,
|
const nsAString& aScriptURL,
|
||||||
@ -2222,21 +2195,11 @@ RuntimeService::CreateSharedWorkerInternal(const GlobalObject& aGlobal,
|
|||||||
false, &loadInfo);
|
false, &loadInfo);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return CreateSharedWorkerFromLoadInfo(cx, loadInfo, aScriptURL, aName, aType,
|
MOZ_ASSERT(loadInfo.mResolvedScriptURI);
|
||||||
aSharedWorker);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsCString scriptSpec;
|
||||||
RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
|
rv = loadInfo.mResolvedScriptURI->GetSpec(scriptSpec);
|
||||||
WorkerPrivate::LoadInfo aLoadInfo,
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
const nsAString& aScriptURL,
|
|
||||||
const nsACString& aName,
|
|
||||||
WorkerType aType,
|
|
||||||
SharedWorker** aSharedWorker)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
|
|
||||||
MOZ_ASSERT(aLoadInfo.mResolvedScriptURI);
|
|
||||||
|
|
||||||
nsRefPtr<WorkerPrivate> workerPrivate;
|
nsRefPtr<WorkerPrivate> workerPrivate;
|
||||||
{
|
{
|
||||||
@ -2245,14 +2208,10 @@ RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
|
|||||||
WorkerDomainInfo* domainInfo;
|
WorkerDomainInfo* domainInfo;
|
||||||
SharedWorkerInfo* sharedWorkerInfo;
|
SharedWorkerInfo* sharedWorkerInfo;
|
||||||
|
|
||||||
nsCString scriptSpec;
|
|
||||||
nsresult rv = aLoadInfo.mResolvedScriptURI->GetSpec(scriptSpec);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsAutoCString key;
|
nsAutoCString key;
|
||||||
GenerateSharedWorkerKey(scriptSpec, aName, key);
|
GenerateSharedWorkerKey(scriptSpec, aName, key);
|
||||||
|
|
||||||
if (mDomainMap.Get(aLoadInfo.mDomain, &domainInfo) &&
|
if (mDomainMap.Get(loadInfo.mDomain, &domainInfo) &&
|
||||||
domainInfo->mSharedWorkerInfos.Get(key, &sharedWorkerInfo)) {
|
domainInfo->mSharedWorkerInfos.Get(key, &sharedWorkerInfo)) {
|
||||||
workerPrivate = sharedWorkerInfo->mWorkerPrivate;
|
workerPrivate = sharedWorkerInfo->mWorkerPrivate;
|
||||||
}
|
}
|
||||||
@ -2263,17 +2222,16 @@ RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
|
|||||||
if (!workerPrivate) {
|
if (!workerPrivate) {
|
||||||
ErrorResult rv;
|
ErrorResult rv;
|
||||||
workerPrivate =
|
workerPrivate =
|
||||||
WorkerPrivate::Constructor(aCx, aScriptURL, false,
|
WorkerPrivate::Constructor(aGlobal, aScriptURL, false,
|
||||||
aType, aName, &aLoadInfo, rv);
|
aType, aName, &loadInfo, rv);
|
||||||
NS_ENSURE_TRUE(workerPrivate, rv.ErrorCode());
|
NS_ENSURE_TRUE(workerPrivate, rv.ErrorCode());
|
||||||
|
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> window = aLoadInfo.mWindow;
|
|
||||||
nsRefPtr<SharedWorker> sharedWorker = new SharedWorker(window, workerPrivate);
|
nsRefPtr<SharedWorker> sharedWorker = new SharedWorker(window, workerPrivate);
|
||||||
|
|
||||||
if (!workerPrivate->RegisterSharedWorker(aCx, sharedWorker)) {
|
if (!workerPrivate->RegisterSharedWorker(cx, sharedWorker)) {
|
||||||
NS_WARNING("Worker is unreachable, this shouldn't happen!");
|
NS_WARNING("Worker is unreachable, this shouldn't happen!");
|
||||||
sharedWorker->Close();
|
sharedWorker->Close();
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "nsClassHashtable.h"
|
#include "nsClassHashtable.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "WorkerPrivate.h"
|
|
||||||
|
|
||||||
class nsIRunnable;
|
class nsIRunnable;
|
||||||
class nsIThread;
|
class nsIThread;
|
||||||
@ -159,13 +158,6 @@ public:
|
|||||||
const nsACString& aScope,
|
const nsACString& aScope,
|
||||||
ServiceWorker** aServiceWorker);
|
ServiceWorker** aServiceWorker);
|
||||||
|
|
||||||
nsresult
|
|
||||||
CreateServiceWorkerFromLoadInfo(JSContext* aCx,
|
|
||||||
WorkerPrivate::LoadInfo aLoadInfo,
|
|
||||||
const nsAString& aScriptURL,
|
|
||||||
const nsACString& aScope,
|
|
||||||
ServiceWorker** aServiceWorker);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ForgetSharedWorker(WorkerPrivate* aWorkerPrivate);
|
ForgetSharedWorker(WorkerPrivate* aWorkerPrivate);
|
||||||
|
|
||||||
@ -304,14 +296,6 @@ private:
|
|||||||
const nsACString& aName,
|
const nsACString& aName,
|
||||||
WorkerType aType,
|
WorkerType aType,
|
||||||
SharedWorker** aSharedWorker);
|
SharedWorker** aSharedWorker);
|
||||||
|
|
||||||
nsresult
|
|
||||||
CreateSharedWorkerFromLoadInfo(JSContext* aCx,
|
|
||||||
WorkerPrivate::LoadInfo aLoadInfo,
|
|
||||||
const nsAString& aScriptURL,
|
|
||||||
const nsACString& aName,
|
|
||||||
WorkerType aType,
|
|
||||||
SharedWorker** aSharedWorker);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
END_WORKERS_NAMESPACE
|
END_WORKERS_NAMESPACE
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "ServiceWorkerManager.h"
|
#include "ServiceWorkerManager.h"
|
||||||
|
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIScriptSecurityManager.h"
|
|
||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
|
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
@ -13,9 +12,6 @@
|
|||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "mozilla/dom/BindingUtils.h"
|
#include "mozilla/dom/BindingUtils.h"
|
||||||
#include "mozilla/dom/DOMError.h"
|
#include "mozilla/dom/DOMError.h"
|
||||||
#include "mozilla/dom/ErrorEvent.h"
|
|
||||||
#include "mozilla/dom/InstallEventBinding.h"
|
|
||||||
#include "mozilla/dom/PromiseNativeHandler.h"
|
|
||||||
|
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsCxPusher.h"
|
#include "nsCxPusher.h"
|
||||||
@ -25,11 +21,9 @@
|
|||||||
|
|
||||||
#include "RuntimeService.h"
|
#include "RuntimeService.h"
|
||||||
#include "ServiceWorker.h"
|
#include "ServiceWorker.h"
|
||||||
#include "ServiceWorkerEvents.h"
|
|
||||||
#include "WorkerInlines.h"
|
#include "WorkerInlines.h"
|
||||||
#include "WorkerPrivate.h"
|
#include "WorkerPrivate.h"
|
||||||
#include "WorkerRunnable.h"
|
#include "WorkerRunnable.h"
|
||||||
#include "WorkerScope.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
@ -118,49 +112,6 @@ UpdatePromise::RejectAllPromises(nsresult aRv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
UpdatePromise::RejectAllPromises(const ErrorEventInit& aErrorDesc)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(mState == Pending);
|
|
||||||
mState = Rejected;
|
|
||||||
|
|
||||||
nsTArray<nsTWeakRef<Promise>> array;
|
|
||||||
array.SwapElements(mPromises);
|
|
||||||
for (uint32_t i = 0; i < array.Length(); ++i) {
|
|
||||||
nsTWeakRef<Promise>& pendingPromise = array.ElementAt(i);
|
|
||||||
if (pendingPromise) {
|
|
||||||
// Since ServiceWorkerContainer is only exposed to windows we can be
|
|
||||||
// certain about this cast.
|
|
||||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(pendingPromise->GetParentObject());
|
|
||||||
MOZ_ASSERT(go);
|
|
||||||
|
|
||||||
AutoJSAPI jsapi;
|
|
||||||
jsapi.Init(go);
|
|
||||||
|
|
||||||
JSContext* cx = jsapi.cx();
|
|
||||||
|
|
||||||
JS::Rooted<JSString*> stack(cx, JS_GetEmptyString(JS_GetRuntime(cx)));
|
|
||||||
|
|
||||||
JS::Rooted<JS::Value> fnval(cx);
|
|
||||||
ToJSValue(cx, aErrorDesc.mFilename, &fnval);
|
|
||||||
JS::Rooted<JSString*> fn(cx, fnval.toString());
|
|
||||||
|
|
||||||
JS::Rooted<JS::Value> msgval(cx);
|
|
||||||
ToJSValue(cx, aErrorDesc.mMessage, &msgval);
|
|
||||||
JS::Rooted<JSString*> msg(cx, msgval.toString());
|
|
||||||
|
|
||||||
JS::Rooted<JS::Value> error(cx);
|
|
||||||
if (!JS::CreateError(cx, JSEXN_ERR, stack, fn, aErrorDesc.mLineno,
|
|
||||||
aErrorDesc.mColno, nullptr, msg, &error)) {
|
|
||||||
pendingPromise->MaybeReject(NS_ERROR_FAILURE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pendingPromise->MaybeReject(cx, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FinishFetchOnMainThreadRunnable : public nsRunnable
|
class FinishFetchOnMainThreadRunnable : public nsRunnable
|
||||||
{
|
{
|
||||||
nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> mUpdateInstance;
|
nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> mUpdateInstance;
|
||||||
@ -227,12 +178,6 @@ public:
|
|||||||
AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
const nsCString&
|
|
||||||
GetScriptSpec() const
|
|
||||||
{
|
|
||||||
return mScriptSpec;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Abort()
|
Abort()
|
||||||
{
|
{
|
||||||
@ -530,16 +475,6 @@ ServiceWorkerManager::RejectUpdatePromiseObservers(ServiceWorkerRegistration* aR
|
|||||||
aRegistration->mUpdatePromise = nullptr;
|
aRegistration->mUpdatePromise = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ServiceWorkerManager::RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
|
|
||||||
const ErrorEventInit& aErrorDesc)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
MOZ_ASSERT(aRegistration->HasUpdatePromise());
|
|
||||||
aRegistration->mUpdatePromise->RejectAllPromises(aErrorDesc);
|
|
||||||
aRegistration->mUpdatePromise = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update() does not return the Promise that the spec says it should. Callers
|
* Update() does not return the Promise that the spec says it should. Callers
|
||||||
* may access the registration's (new) Promise after calling this method.
|
* may access the registration's (new) Promise after calling this method.
|
||||||
@ -654,302 +589,11 @@ ServiceWorkerManager::FinishFetch(ServiceWorkerRegistration* aRegistration,
|
|||||||
Install(aRegistration, info);
|
Install(aRegistration, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ServiceWorkerManager::HandleError(JSContext* aCx,
|
|
||||||
const nsACString& aScope,
|
|
||||||
const nsAString& aWorkerURL,
|
|
||||||
nsString aMessage,
|
|
||||||
nsString aFilename,
|
|
||||||
nsString aLine,
|
|
||||||
uint32_t aLineNumber,
|
|
||||||
uint32_t aColumnNumber,
|
|
||||||
uint32_t aFlags)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
|
||||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aScope, nullptr, nullptr);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCString domain;
|
|
||||||
rv = uri->GetHost(domain);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceWorkerDomainInfo* domainInfo;
|
|
||||||
if (!mDomainMap.Get(domain, &domainInfo)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCString scope;
|
|
||||||
scope.Assign(aScope);
|
|
||||||
nsRefPtr<ServiceWorkerRegistration> registration = domainInfo->GetRegistration(scope);
|
|
||||||
MOZ_ASSERT(registration);
|
|
||||||
|
|
||||||
ErrorEventInit init;
|
|
||||||
init.mMessage = aMessage;
|
|
||||||
init.mFilename = aFilename;
|
|
||||||
init.mLineno = aLineNumber;
|
|
||||||
init.mColno = aColumnNumber;
|
|
||||||
|
|
||||||
// If the worker was the one undergoing registration, we reject the promises,
|
|
||||||
// otherwise we fire events on the ServiceWorker instances.
|
|
||||||
|
|
||||||
// If there is an update in progress and the worker that errored is the same one
|
|
||||||
// that is being updated, it is a sufficient test for 'this worker is being
|
|
||||||
// registered'.
|
|
||||||
// FIXME(nsm): Except the case where an update is found for a worker, in
|
|
||||||
// which case we'll need some other association than simply the URL.
|
|
||||||
if (registration->mUpdateInstance &&
|
|
||||||
registration->mUpdateInstance->GetScriptSpec().Equals(NS_ConvertUTF16toUTF8(aWorkerURL))) {
|
|
||||||
RejectUpdatePromiseObservers(registration, init);
|
|
||||||
// We don't need to abort here since the worker has already run.
|
|
||||||
registration->mUpdateInstance = nullptr;
|
|
||||||
} else {
|
|
||||||
// FIXME(nsm): Bug 983497 Fire 'error' on ServiceWorkerContainers.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FinishInstallRunnable MOZ_FINAL : public nsRunnable
|
|
||||||
{
|
|
||||||
nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit FinishInstallRunnable(
|
|
||||||
const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
|
|
||||||
: mRegistration(aRegistration)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!NS_IsMainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
Run() MOZ_OVERRIDE
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
|
|
||||||
nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
|
||||||
swm->FinishInstall(mRegistration.get());
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class CancelServiceWorkerInstallationRunnable MOZ_FINAL : public nsRunnable
|
|
||||||
{
|
|
||||||
nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CancelServiceWorkerInstallationRunnable(
|
|
||||||
const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
|
|
||||||
: mRegistration(aRegistration)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
Run() MOZ_OVERRIDE
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
// FIXME(nsm): Change installing worker state to redundant.
|
|
||||||
// FIXME(nsm): Fire statechange.
|
|
||||||
mRegistration->mInstallingWorker.Invalidate();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used to handle InstallEvent::waitUntil() and proceed with installation.
|
|
||||||
*/
|
|
||||||
class FinishInstallHandler MOZ_FINAL : public PromiseNativeHandler
|
|
||||||
{
|
|
||||||
nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~FinishInstallHandler()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit FinishInstallHandler(
|
|
||||||
const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
|
|
||||||
: mRegistration(aRegistration)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!NS_IsMainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) MOZ_OVERRIDE
|
|
||||||
{
|
|
||||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
|
||||||
MOZ_ASSERT(workerPrivate);
|
|
||||||
workerPrivate->AssertIsOnWorkerThread();
|
|
||||||
|
|
||||||
nsRefPtr<FinishInstallRunnable> r = new FinishInstallRunnable(mRegistration);
|
|
||||||
NS_DispatchToMainThread(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) MOZ_OVERRIDE
|
|
||||||
{
|
|
||||||
nsRefPtr<CancelServiceWorkerInstallationRunnable> r =
|
|
||||||
new CancelServiceWorkerInstallationRunnable(mRegistration);
|
|
||||||
NS_DispatchToMainThread(r);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fires 'install' event on the ServiceWorkerGlobalScope. Modifies busy count
|
|
||||||
* since it fires the event. This is ok since there can't be nested
|
|
||||||
* ServiceWorkers, so the parent thread -> worker thread requirement for
|
|
||||||
* runnables is satisfied.
|
|
||||||
*/
|
|
||||||
class InstallEventRunnable MOZ_FINAL : public WorkerRunnable
|
|
||||||
{
|
|
||||||
nsMainThreadPtrHandle<ServiceWorkerRegistration> mRegistration;
|
|
||||||
nsCString mScope;
|
|
||||||
|
|
||||||
public:
|
|
||||||
InstallEventRunnable(
|
|
||||||
WorkerPrivate* aWorkerPrivate,
|
|
||||||
const nsMainThreadPtrHandle<ServiceWorkerRegistration>& aRegistration)
|
|
||||||
: WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount),
|
|
||||||
mRegistration(aRegistration),
|
|
||||||
mScope(aRegistration.get()->mScope) // copied for access on worker thread.
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
MOZ_ASSERT(aWorkerPrivate);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aWorkerPrivate);
|
|
||||||
return DispatchInstallEvent(aCx, aWorkerPrivate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool
|
|
||||||
DispatchInstallEvent(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
|
||||||
{
|
|
||||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
|
||||||
MOZ_ASSERT(aWorkerPrivate->IsServiceWorker());
|
|
||||||
InstallEventInit init;
|
|
||||||
init.mBubbles = false;
|
|
||||||
init.mCancelable = true;
|
|
||||||
|
|
||||||
// FIXME(nsm): Bug 982787 pass previous active worker.
|
|
||||||
|
|
||||||
nsRefPtr<EventTarget> target = aWorkerPrivate->GlobalScope();
|
|
||||||
nsRefPtr<InstallEvent> event =
|
|
||||||
InstallEvent::Constructor(target, NS_LITERAL_STRING("install"), init);
|
|
||||||
|
|
||||||
event->SetTrusted(true);
|
|
||||||
|
|
||||||
nsRefPtr<Promise> waitUntilPromise;
|
|
||||||
|
|
||||||
nsresult rv = target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIGlobalObject> sgo = aWorkerPrivate->GlobalScope();
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
waitUntilPromise = event->GetPromise();
|
|
||||||
if (!waitUntilPromise) {
|
|
||||||
ErrorResult rv;
|
|
||||||
waitUntilPromise =
|
|
||||||
Promise::Resolve(sgo,
|
|
||||||
aCx, JS::UndefinedHandleValue, rv);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ErrorResult rv;
|
|
||||||
// Continue with a canceled install.
|
|
||||||
waitUntilPromise = Promise::Reject(sgo, aCx,
|
|
||||||
JS::UndefinedHandleValue, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRefPtr<FinishInstallHandler> handler =
|
|
||||||
new FinishInstallHandler(mRegistration);
|
|
||||||
waitUntilPromise->AppendNativeHandler(handler);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ServiceWorkerManager::Install(ServiceWorkerRegistration* aRegistration,
|
ServiceWorkerManager::Install(ServiceWorkerRegistration* aRegistration,
|
||||||
ServiceWorkerInfo aServiceWorkerInfo)
|
ServiceWorkerInfo aServiceWorkerInfo)
|
||||||
{
|
{
|
||||||
AssertIsOnMainThread();
|
// FIXME(nsm): Same bug, different patch.
|
||||||
aRegistration->mInstallingWorker = aServiceWorkerInfo;
|
|
||||||
|
|
||||||
nsMainThreadPtrHandle<ServiceWorkerRegistration> handle =
|
|
||||||
new nsMainThreadPtrHolder<ServiceWorkerRegistration>(aRegistration);
|
|
||||||
|
|
||||||
nsRefPtr<ServiceWorker> serviceWorker;
|
|
||||||
nsresult rv =
|
|
||||||
CreateServiceWorker(aServiceWorkerInfo.GetScriptSpec(),
|
|
||||||
aRegistration->mScope,
|
|
||||||
getter_AddRefs(serviceWorker));
|
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
aRegistration->mInstallingWorker.Invalidate();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRefPtr<InstallEventRunnable> r =
|
|
||||||
new InstallEventRunnable(serviceWorker->GetWorkerPrivate(), handle);
|
|
||||||
|
|
||||||
AutoSafeJSContext cx;
|
|
||||||
r->Dispatch(cx);
|
|
||||||
|
|
||||||
// When this function exits, although we've lost references to the ServiceWorker,
|
|
||||||
// which means the underlying WorkerPrivate has no references, the worker
|
|
||||||
// will stay alive due to the modified busy count until the install event has
|
|
||||||
// been dispatched.
|
|
||||||
// NOTE: The worker spec does not require Promises to keep a worker alive, so
|
|
||||||
// the waitUntil() construct by itself will not keep a worker alive beyond
|
|
||||||
// the event dispatch. On the other hand, networking, IDB and so on do keep
|
|
||||||
// the worker alive, so the waitUntil() is only relevant if the Promise is
|
|
||||||
// gated on those actions. I (nsm) am not sure if it is worth requiring
|
|
||||||
// a special spec mention saying the install event should keep the worker
|
|
||||||
// alive indefinitely purely on the basis of calling waitUntil(), since
|
|
||||||
// a wait is likely to be required only when performing networking or storage
|
|
||||||
// transactions in the first place.
|
|
||||||
|
|
||||||
// FIXME(nsm): Bug 983497. Fire "updatefound" on ServiceWorkerContainers.
|
|
||||||
}
|
|
||||||
|
|
||||||
class ActivationRunnable : public nsRunnable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ActivationRunnable(ServiceWorkerRegistration* aRegistration)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
ServiceWorkerManager::FinishInstall(ServiceWorkerRegistration* aRegistration)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
|
|
||||||
if (aRegistration->mWaitingWorker.IsValid()) {
|
|
||||||
// FIXME(nsm): Actually update the state of active ServiceWorker instances.
|
|
||||||
}
|
|
||||||
|
|
||||||
aRegistration->mWaitingWorker = aRegistration->mInstallingWorker;
|
|
||||||
aRegistration->mInstallingWorker.Invalidate();
|
|
||||||
|
|
||||||
// FIXME(nsm): Actually update state of active ServiceWorker instances to
|
|
||||||
// installed.
|
|
||||||
// FIXME(nsm): Fire statechange on the instances.
|
|
||||||
|
|
||||||
// FIXME(nsm): Handle replace().
|
|
||||||
|
|
||||||
// FIXME(nsm): Check that no document is using the registration!
|
|
||||||
|
|
||||||
nsRefPtr<ActivationRunnable> r =
|
|
||||||
new ActivationRunnable(aRegistration);
|
|
||||||
|
|
||||||
nsresult rv = NS_DispatchToMainThread(r);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
// FIXME(nsm): Handle error.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@ -984,52 +628,4 @@ ServiceWorkerManager::CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
ServiceWorkerManager::CreateServiceWorker(const nsACString& aScriptSpec,
|
|
||||||
const nsACString& aScope,
|
|
||||||
ServiceWorker** aServiceWorker)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
|
|
||||||
WorkerPrivate::LoadInfo info;
|
|
||||||
nsresult rv = NS_NewURI(getter_AddRefs(info.mBaseURI), aScriptSpec, nullptr, nullptr);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
info.mResolvedScriptURI = info.mBaseURI;
|
|
||||||
|
|
||||||
rv = info.mBaseURI->GetHost(info.mDomain);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME(nsm): Create correct principal based on app-ness.
|
|
||||||
// Would it make sense to store the nsIPrincipal of the first register() in
|
|
||||||
// the ServiceWorkerRegistration and use that?
|
|
||||||
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
|
||||||
rv = ssm->GetNoAppCodebasePrincipal(info.mBaseURI, getter_AddRefs(info.mPrincipal));
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoSafeJSContext cx;
|
|
||||||
|
|
||||||
nsRefPtr<ServiceWorker> serviceWorker;
|
|
||||||
RuntimeService* rs = RuntimeService::GetService();
|
|
||||||
if (!rs) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = rs->CreateServiceWorkerFromLoadInfo(cx, info, NS_ConvertUTF8toUTF16(aScriptSpec), aScope,
|
|
||||||
getter_AddRefs(serviceWorker));
|
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
serviceWorker.forget(aServiceWorker);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
END_WORKERS_NAMESPACE
|
END_WORKERS_NAMESPACE
|
||||||
|
@ -18,14 +18,11 @@
|
|||||||
#include "nsTArrayForwardDeclare.h"
|
#include "nsTArrayForwardDeclare.h"
|
||||||
#include "nsTWeakRef.h"
|
#include "nsTWeakRef.h"
|
||||||
|
|
||||||
class nsIScriptError;
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
namespace workers {
|
namespace workers {
|
||||||
|
|
||||||
class ServiceWorker;
|
class ServiceWorker;
|
||||||
class ServiceWorkerContainer;
|
|
||||||
class ServiceWorkerUpdateInstance;
|
class ServiceWorkerUpdateInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +43,6 @@ public:
|
|||||||
void AddPromise(Promise* aPromise);
|
void AddPromise(Promise* aPromise);
|
||||||
void ResolveAllPromises(const nsACString& aScriptSpec, const nsACString& aScope);
|
void ResolveAllPromises(const nsACString& aScriptSpec, const nsACString& aScope);
|
||||||
void RejectAllPromises(nsresult aRv);
|
void RejectAllPromises(nsresult aRv);
|
||||||
void RejectAllPromises(const ErrorEventInit& aErrorDesc);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsRejected() const
|
IsRejected() const
|
||||||
@ -234,28 +230,10 @@ public:
|
|||||||
RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
|
RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
|
||||||
nsresult aResult);
|
nsresult aResult);
|
||||||
|
|
||||||
void
|
|
||||||
RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
|
|
||||||
const ErrorEventInit& aErrorDesc);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FinishFetch(ServiceWorkerRegistration* aRegistration,
|
FinishFetch(ServiceWorkerRegistration* aRegistration,
|
||||||
nsPIDOMWindow* aWindow);
|
nsPIDOMWindow* aWindow);
|
||||||
|
|
||||||
void
|
|
||||||
FinishInstall(ServiceWorkerRegistration* aRegistration);
|
|
||||||
|
|
||||||
void
|
|
||||||
HandleError(JSContext* aCx,
|
|
||||||
const nsACString& aScope,
|
|
||||||
const nsAString& aWorkerURL,
|
|
||||||
nsString aMessage,
|
|
||||||
nsString aFilename,
|
|
||||||
nsString aLine,
|
|
||||||
uint32_t aLineNumber,
|
|
||||||
uint32_t aColumnNumber,
|
|
||||||
uint32_t aFlags);
|
|
||||||
|
|
||||||
static already_AddRefed<ServiceWorkerManager>
|
static already_AddRefed<ServiceWorkerManager>
|
||||||
GetInstance();
|
GetInstance();
|
||||||
|
|
||||||
@ -270,17 +248,12 @@ private:
|
|||||||
Install(ServiceWorkerRegistration* aRegistration,
|
Install(ServiceWorkerRegistration* aRegistration,
|
||||||
ServiceWorkerInfo aServiceWorkerInfo);
|
ServiceWorkerInfo aServiceWorkerInfo);
|
||||||
|
|
||||||
NS_IMETHOD
|
NS_IMETHODIMP
|
||||||
CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
|
CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
|
||||||
const nsACString& aScriptSpec,
|
const nsACString& aScriptSpec,
|
||||||
const nsACString& aScope,
|
const nsACString& aScope,
|
||||||
ServiceWorker** aServiceWorker);
|
ServiceWorker** aServiceWorker);
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
CreateServiceWorker(const nsACString& aScriptSpec,
|
|
||||||
const nsACString& aScope,
|
|
||||||
ServiceWorker** aServiceWorker);
|
|
||||||
|
|
||||||
static PLDHashOperator
|
static PLDHashOperator
|
||||||
CleanupServiceWorkerInformation(const nsACString& aDomain,
|
CleanupServiceWorkerInformation(const nsACString& aDomain,
|
||||||
ServiceWorkerDomainInfo* aDomainInfo,
|
ServiceWorkerDomainInfo* aDomainInfo,
|
||||||
|
@ -77,7 +77,6 @@
|
|||||||
#include "Principal.h"
|
#include "Principal.h"
|
||||||
#include "RuntimeService.h"
|
#include "RuntimeService.h"
|
||||||
#include "ScriptLoader.h"
|
#include "ScriptLoader.h"
|
||||||
#include "ServiceWorkerManager.h"
|
|
||||||
#include "SharedWorker.h"
|
#include "SharedWorker.h"
|
||||||
#include "WorkerFeature.h"
|
#include "WorkerFeature.h"
|
||||||
#include "WorkerRunnable.h"
|
#include "WorkerRunnable.h"
|
||||||
@ -1323,15 +1322,7 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aWorkerPrivate->IsServiceWorker()) {
|
if (aWorkerPrivate->IsSharedWorker() || aWorkerPrivate->IsServiceWorker()) {
|
||||||
nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
|
||||||
MOZ_ASSERT(swm);
|
|
||||||
swm->HandleError(aCx, aWorkerPrivate->SharedWorkerName(),
|
|
||||||
aWorkerPrivate->ScriptURL(),
|
|
||||||
mMessage,
|
|
||||||
mFilename, mLine, mLineNumber, mColumnNumber, mFlags);
|
|
||||||
return true;
|
|
||||||
} else if (aWorkerPrivate->IsSharedWorker()) {
|
|
||||||
aWorkerPrivate->BroadcastErrorToSharedWorkers(aCx, mMessage, mFilename,
|
aWorkerPrivate->BroadcastErrorToSharedWorkers(aCx, mMessage, mFilename,
|
||||||
mLine, mLineNumber,
|
mLine, mLineNumber,
|
||||||
mColumnNumber, mFlags);
|
mColumnNumber, mFlags);
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
oninstall = function(e) {
|
|
||||||
dump("NSM Got install event\n");
|
|
||||||
dump(e.activeWorker);
|
|
||||||
}
|
|
@ -3,9 +3,6 @@ support-files =
|
|||||||
worker.js
|
worker.js
|
||||||
worker2.js
|
worker2.js
|
||||||
worker3.js
|
worker3.js
|
||||||
parse_error_worker.js
|
|
||||||
install_event_worker.js
|
|
||||||
|
|
||||||
[test_installation_simple.html]
|
[test_installation_simple.html]
|
||||||
[test_install_event.html]
|
|
||||||
[test_navigator.html]
|
[test_navigator.html]
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
// intentional parse error.
|
|
||||||
var foo = {;
|
|
@ -1,49 +0,0 @@
|
|||||||
<!--
|
|
||||||
Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
-->
|
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Bug 94048 - test install event.</title>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p id="display"></p>
|
|
||||||
<div id="content" style="display: none"></div>
|
|
||||||
<pre id="test"></pre>
|
|
||||||
<script class="testbody" type="text/javascript">
|
|
||||||
|
|
||||||
function simpleRegister() {
|
|
||||||
var p = navigator.serviceWorker.register("worker.js");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
function nextRegister() {
|
|
||||||
var p = navigator.serviceWorker.register("install_event_worker.js");
|
|
||||||
todo(false, "Check for onupdatefound event");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
function runTest() {
|
|
||||||
simpleRegister()
|
|
||||||
.then(nextRegister)
|
|
||||||
.then(function() {
|
|
||||||
SimpleTest.finish();
|
|
||||||
}).catch(function(e) {
|
|
||||||
ok(false, "Some test failed with error " + e);
|
|
||||||
SimpleTest.finish();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
|
||||||
SpecialPowers.pushPrefEnv({"set": [
|
|
||||||
["dom.serviceWorkers.enabled", true],
|
|
||||||
["dom.serviceWorkers.testing.enabled", true]
|
|
||||||
]}, runTest);
|
|
||||||
</script>
|
|
||||||
</pre>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -63,8 +63,8 @@
|
|||||||
ok(w.scope == (new URL("/*", document.baseURI)).href, "Scope should match");
|
ok(w.scope == (new URL("/*", document.baseURI)).href, "Scope should match");
|
||||||
ok(w.url == (new URL("worker.js", document.baseURI)).href, "URL should be of the worker");
|
ok(w.url == (new URL("worker.js", document.baseURI)).href, "URL should be of the worker");
|
||||||
}, function(e) {
|
}, function(e) {
|
||||||
info("Error: " + e.name);
|
info(e.name);
|
||||||
ok(false, "realWorker Registration should have succeeded!");
|
ok(false, "Registration should have succeeded!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,18 +95,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseError() {
|
|
||||||
var p = navigator.serviceWorker.register("parse_error_worker.js");
|
|
||||||
return p.then(function(w) {
|
|
||||||
ok(false, "Registration should fail with parse error");
|
|
||||||
}, function(e) {
|
|
||||||
info("NSM " + e.name);
|
|
||||||
ok(e instanceof Error, "Registration should fail with parse error");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME(nsm): test for parse error when Update step doesn't happen (directly from register).
|
|
||||||
|
|
||||||
function runTest() {
|
function runTest() {
|
||||||
simpleRegister()
|
simpleRegister()
|
||||||
.then(sameOriginWorker)
|
.then(sameOriginWorker)
|
||||||
@ -114,8 +102,8 @@
|
|||||||
.then(httpsOnly)
|
.then(httpsOnly)
|
||||||
.then(realWorker)
|
.then(realWorker)
|
||||||
.then(abortPrevious)
|
.then(abortPrevious)
|
||||||
.then(networkError404)
|
// FIXME(nsm): Uncomment once we have the error trapping patch from Bug 984048.
|
||||||
.then(parseError)
|
// .then(networkError404)
|
||||||
// put more tests here.
|
// put more tests here.
|
||||||
.then(function() {
|
.then(function() {
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "jsapi-tests/tests.h"
|
#include "jsapi-tests/tests.h"
|
||||||
|
|
||||||
using JS::CreateError;
|
using JS::CreateTypeError;
|
||||||
using JS::Rooted;
|
using JS::Rooted;
|
||||||
using JS::ObjectValue;
|
using JS::ObjectValue;
|
||||||
using JS::Value;
|
using JS::Value;
|
||||||
@ -22,7 +22,7 @@ BEGIN_TEST(testUncaughtError)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
Rooted<Value> err(cx);
|
Rooted<Value> err(cx);
|
||||||
if (!CreateError(cx, JSEXN_TYPEERR, empty, empty, 0, 0, nullptr, empty, &err))
|
if (!CreateTypeError(cx, empty, empty, 0, 0, nullptr, empty, &err))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Rooted<JSObject*> errObj(cx, &err.toObject());
|
Rooted<JSObject*> errObj(cx, &err.toObject());
|
||||||
|
@ -4606,9 +4606,9 @@ JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
|
|||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
CreateError(JSContext *cx, JSExnType type, HandleString stack,
|
CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
|
||||||
HandleString fileName, uint32_t lineNumber, uint32_t columnNumber,
|
uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
|
||||||
JSErrorReport *report, HandleString message, MutableHandleValue rval);
|
HandleString message, MutableHandleValue rval);
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
@ -915,7 +915,7 @@ js_CopyErrorObject(JSContext *cx, Handle<ErrorObject*> err, HandleObject scope)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(bool)
|
JS_PUBLIC_API(bool)
|
||||||
JS::CreateError(JSContext *cx, JSExnType type, HandleString stack, HandleString fileName,
|
JS::CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
|
||||||
uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
|
uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
|
||||||
HandleString message, MutableHandleValue rval)
|
HandleString message, MutableHandleValue rval)
|
||||||
{
|
{
|
||||||
@ -925,7 +925,7 @@ JS::CreateError(JSContext *cx, JSExnType type, HandleString stack, HandleString
|
|||||||
rep = CopyErrorReport(cx, report);
|
rep = CopyErrorReport(cx, report);
|
||||||
|
|
||||||
RootedObject obj(cx,
|
RootedObject obj(cx,
|
||||||
js::ErrorObject::create(cx, type, stack, fileName,
|
js::ErrorObject::create(cx, JSEXN_TYPEERR, stack, fileName,
|
||||||
lineNumber, columnNumber, &rep, message));
|
lineNumber, columnNumber, &rep, message));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user