Backed out 3 changesets (bug 984048) for breaking hazard builds.

Backed out changeset 2d0c34b7045f (bug 984048)
Backed out changeset c18211a2afa1 (bug 984048)
Backed out changeset 30fa36882d57 (bug 984048)
This commit is contained in:
Wes Kocher 2014-07-01 20:29:08 -07:00
parent af7ae55f0c
commit bbc09af3cc
14 changed files with 25 additions and 597 deletions

View File

@ -278,8 +278,8 @@ WrapperPromiseCallback::Call(JSContext* aCx,
}
JS::Rooted<JS::Value> typeError(aCx);
if (!JS::CreateError(aCx, JSEXN_TYPEERR, stack, fn, lineNumber, 0,
nullptr, message, &typeError)) {
if (!JS::CreateTypeError(aCx, stack, fn, lineNumber, 0,
nullptr, message, &typeError)) {
// Out of memory. Promise will stay unresolved.
JS_ClearPendingException(aCx);
return;

View File

@ -2175,33 +2175,6 @@ RuntimeService::CreateServiceWorker(const GlobalObject& aGlobal,
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
RuntimeService::CreateSharedWorkerInternal(const GlobalObject& aGlobal,
const nsAString& aScriptURL,
@ -2222,21 +2195,11 @@ RuntimeService::CreateSharedWorkerInternal(const GlobalObject& aGlobal,
false, &loadInfo);
NS_ENSURE_SUCCESS(rv, rv);
return CreateSharedWorkerFromLoadInfo(cx, loadInfo, aScriptURL, aName, aType,
aSharedWorker);
}
MOZ_ASSERT(loadInfo.mResolvedScriptURI);
nsresult
RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
WorkerPrivate::LoadInfo aLoadInfo,
const nsAString& aScriptURL,
const nsACString& aName,
WorkerType aType,
SharedWorker** aSharedWorker)
{
AssertIsOnMainThread();
MOZ_ASSERT(aLoadInfo.mResolvedScriptURI);
nsCString scriptSpec;
rv = loadInfo.mResolvedScriptURI->GetSpec(scriptSpec);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<WorkerPrivate> workerPrivate;
{
@ -2245,31 +2208,22 @@ RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
WorkerDomainInfo* domainInfo;
SharedWorkerInfo* sharedWorkerInfo;
nsCString scriptSpec;
nsresult rv = aLoadInfo.mResolvedScriptURI->GetSpec(scriptSpec);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString key;
GenerateSharedWorkerKey(scriptSpec, aName, key);
if (mDomainMap.Get(aLoadInfo.mDomain, &domainInfo) &&
if (mDomainMap.Get(loadInfo.mDomain, &domainInfo) &&
domainInfo->mSharedWorkerInfos.Get(key, &sharedWorkerInfo)) {
workerPrivate = sharedWorkerInfo->mWorkerPrivate;
}
}
// Keep a reference to the window before spawning the worker. If the worker is
// a Shared/Service worker and the worker script loads and executes before
// the SharedWorker object itself is created before then WorkerScriptLoaded()
// will reset the loadInfo's window.
nsCOMPtr<nsPIDOMWindow> window = aLoadInfo.mWindow;
bool created = false;
if (!workerPrivate) {
ErrorResult rv;
workerPrivate =
WorkerPrivate::Constructor(aCx, aScriptURL, false,
aType, aName, &aLoadInfo, rv);
WorkerPrivate::Constructor(aGlobal, aScriptURL, false,
aType, aName, &loadInfo, rv);
NS_ENSURE_TRUE(workerPrivate, rv.ErrorCode());
created = true;
@ -2277,7 +2231,7 @@ RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
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!");
sharedWorker->Close();
return NS_ERROR_FAILURE;

View File

@ -17,7 +17,6 @@
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsTArray.h"
#include "WorkerPrivate.h"
class nsIRunnable;
class nsIThread;
@ -159,13 +158,6 @@ public:
const nsACString& aScope,
ServiceWorker** aServiceWorker);
nsresult
CreateServiceWorkerFromLoadInfo(JSContext* aCx,
WorkerPrivate::LoadInfo aLoadInfo,
const nsAString& aScriptURL,
const nsACString& aScope,
ServiceWorker** aServiceWorker);
void
ForgetSharedWorker(WorkerPrivate* aWorkerPrivate);
@ -304,14 +296,6 @@ private:
const nsACString& aName,
WorkerType aType,
SharedWorker** aSharedWorker);
nsresult
CreateSharedWorkerFromLoadInfo(JSContext* aCx,
WorkerPrivate::LoadInfo aLoadInfo,
const nsAString& aScriptURL,
const nsACString& aName,
WorkerType aType,
SharedWorker** aSharedWorker);
};
END_WORKERS_NAMESPACE

View File

@ -5,7 +5,6 @@
#include "ServiceWorkerManager.h"
#include "nsIDocument.h"
#include "nsIScriptSecurityManager.h"
#include "nsPIDOMWindow.h"
#include "jsapi.h"
@ -13,9 +12,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/dom/BindingUtils.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 "nsCxPusher.h"
@ -25,11 +21,9 @@
#include "RuntimeService.h"
#include "ServiceWorker.h"
#include "ServiceWorkerEvents.h"
#include "WorkerInlines.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
using namespace mozilla;
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
{
nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> mUpdateInstance;
@ -227,12 +178,6 @@ public:
AssertIsOnMainThread();
}
const nsCString&
GetScriptSpec() const
{
return mScriptSpec;
}
void
Abort()
{
@ -530,16 +475,6 @@ ServiceWorkerManager::RejectUpdatePromiseObservers(ServiceWorkerRegistration* aR
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
* may access the registration's (new) Promise after calling this method.
@ -654,302 +589,11 @@ ServiceWorkerManager::FinishFetch(ServiceWorkerRegistration* aRegistration,
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
ServiceWorkerManager::Install(ServiceWorkerRegistration* aRegistration,
ServiceWorkerInfo aServiceWorkerInfo)
{
AssertIsOnMainThread();
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.
}
// FIXME(nsm): Same bug, different patch.
}
NS_IMETHODIMP
@ -984,52 +628,4 @@ ServiceWorkerManager::CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
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

View File

@ -18,14 +18,11 @@
#include "nsTArrayForwardDeclare.h"
#include "nsTWeakRef.h"
class nsIScriptError;
namespace mozilla {
namespace dom {
namespace workers {
class ServiceWorker;
class ServiceWorkerContainer;
class ServiceWorkerUpdateInstance;
/**
@ -46,7 +43,6 @@ public:
void AddPromise(Promise* aPromise);
void ResolveAllPromises(const nsACString& aScriptSpec, const nsACString& aScope);
void RejectAllPromises(nsresult aRv);
void RejectAllPromises(const ErrorEventInit& aErrorDesc);
bool
IsRejected() const
@ -234,28 +230,10 @@ public:
RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
nsresult aResult);
void
RejectUpdatePromiseObservers(ServiceWorkerRegistration* aRegistration,
const ErrorEventInit& aErrorDesc);
void
FinishFetch(ServiceWorkerRegistration* aRegistration,
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>
GetInstance();
@ -270,17 +248,12 @@ private:
Install(ServiceWorkerRegistration* aRegistration,
ServiceWorkerInfo aServiceWorkerInfo);
NS_IMETHOD
NS_IMETHODIMP
CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow,
const nsACString& aScriptSpec,
const nsACString& aScope,
ServiceWorker** aServiceWorker);
NS_IMETHOD
CreateServiceWorker(const nsACString& aScriptSpec,
const nsACString& aScope,
ServiceWorker** aServiceWorker);
static PLDHashOperator
CleanupServiceWorkerInformation(const nsACString& aDomain,
ServiceWorkerDomainInfo* aDomainInfo,

View File

@ -77,7 +77,6 @@
#include "Principal.h"
#include "RuntimeService.h"
#include "ScriptLoader.h"
#include "ServiceWorkerManager.h"
#include "SharedWorker.h"
#include "WorkerFeature.h"
#include "WorkerRunnable.h"
@ -1334,15 +1333,7 @@ private:
return true;
}
if (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()) {
if (aWorkerPrivate->IsSharedWorker() || aWorkerPrivate->IsServiceWorker()) {
aWorkerPrivate->BroadcastErrorToSharedWorkers(aCx, mMessage, mFilename,
mLine, mLineNumber,
mColumnNumber, mFlags);

View File

@ -1,4 +0,0 @@
oninstall = function(e) {
dump("NSM Got install event\n");
dump(e.activeWorker);
}

View File

@ -3,9 +3,6 @@ support-files =
worker.js
worker2.js
worker3.js
parse_error_worker.js
install_event_worker.js
[test_installation_simple.html]
[test_install_event.html]
[test_navigator.html]

View File

@ -1,2 +0,0 @@
// intentional parse error.
var foo = {;

View File

@ -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>

View File

@ -63,8 +63,8 @@
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");
}, function(e) {
info("Error: " + e.name);
ok(false, "realWorker Registration should have succeeded!");
info(e.name);
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() {
simpleRegister()
.then(sameOriginWorker)
@ -114,8 +102,8 @@
.then(httpsOnly)
.then(realWorker)
.then(abortPrevious)
.then(networkError404)
.then(parseError)
// FIXME(nsm): Uncomment once we have the error trapping patch from Bug 984048.
// .then(networkError404)
// put more tests here.
.then(function() {
SimpleTest.finish();

View File

@ -4,7 +4,7 @@
#include "jsapi-tests/tests.h"
using JS::CreateError;
using JS::CreateTypeError;
using JS::Rooted;
using JS::ObjectValue;
using JS::Value;
@ -22,7 +22,7 @@ BEGIN_TEST(testUncaughtError)
return false;
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;
Rooted<JSObject*> errObj(cx, &err.toObject());

View File

@ -4624,9 +4624,9 @@ JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
namespace JS {
extern JS_PUBLIC_API(bool)
CreateError(JSContext *cx, JSExnType type, HandleString stack,
HandleString fileName, uint32_t lineNumber, uint32_t columnNumber,
JSErrorReport *report, HandleString message, MutableHandleValue rval);
CreateTypeError(JSContext *cx, HandleString stack, HandleString fileName,
uint32_t lineNumber, uint32_t columnNumber, JSErrorReport *report,
HandleString message, MutableHandleValue rval);
/************************************************************************/

View File

@ -915,7 +915,7 @@ js_CopyErrorObject(JSContext *cx, Handle<ErrorObject*> err, HandleObject scope)
}
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,
HandleString message, MutableHandleValue rval)
{
@ -925,7 +925,7 @@ JS::CreateError(JSContext *cx, JSExnType type, HandleString stack, HandleString
rep = CopyErrorReport(cx, report);
RootedObject obj(cx,
js::ErrorObject::create(cx, type, stack, fileName,
js::ErrorObject::create(cx, JSEXN_TYPEERR, stack, fileName,
lineNumber, columnNumber, &rep, message));
if (!obj)
return false;