Backed out changeset 062c0a4db943 (bug 982726) for m4 test failures

This commit is contained in:
Carsten "Tomcat" Book 2014-10-28 12:31:07 +01:00
parent efa123b380
commit ec1cf2ce61
20 changed files with 6 additions and 626 deletions

View File

@ -931,16 +931,6 @@ DOMInterfaces = {
'headerFile': 'mozilla/dom/workers/bindings/ServiceWorker.h',
},
'ServiceWorkerClient': {
'nativeType': 'mozilla::dom::workers::ServiceWorkerClient',
'headerFile': 'mozilla/dom/workers/bindings/ServiceWorkerClient.h',
},
'ServiceWorkerClients': {
'nativeType': 'mozilla::dom::workers::ServiceWorkerClients',
'headerFile': 'mozilla/dom/workers/bindings/ServiceWorkerClients.h',
},
'ServiceWorkerGlobalScope': {
'headerFile': 'mozilla/dom/WorkerScope.h',
'workers': True,

View File

@ -1,14 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html
*
*/
[Exposed=ServiceWorker]
interface ServiceWorkerClient {
readonly attribute unsigned long id;
};

View File

@ -1,19 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html
*
*/
[Exposed=ServiceWorker]
interface ServiceWorkerClients {
// A list of client objects, identifiable by ID, that correspond to windows
// (or workers) that are "controlled" by this SW
[Throws]
Promise<sequence<ServiceWorkerClient>?> getServiced();
[Throws]
Promise<any> reloadAll();
};

View File

@ -16,7 +16,10 @@ interface ServiceWorkerGlobalScope : WorkerGlobalScope {
// FIXME(nsm): Bug 982725
// readonly attribute CacheList caches;
readonly attribute ServiceWorkerClients clients;
// FIXME(nsm): Bug 982726
// A container for a list of window objects, identifiable by ID, that
// correspond to windows (or workers) that are "controlled" by this SW
// readonly attribute ServiceWorkerClients clients;
[Unforgeable] readonly attribute DOMString scope;

View File

@ -354,8 +354,6 @@ WEBIDL_FILES = [
'ScrollBoxObject.webidl',
'Selection.webidl',
'ServiceWorker.webidl',
'ServiceWorkerClient.webidl',
'ServiceWorkerClients.webidl',
'ServiceWorkerContainer.webidl',
'ServiceWorkerGlobalScope.webidl',
'ServiceWorkerRegistration.webidl',

View File

@ -1,29 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "ServiceWorkerClient.h"
#include "mozilla/dom/ServiceWorkerClientBinding.h"
using namespace mozilla::dom;
using namespace mozilla::dom::workers;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ServiceWorkerClient, mOwner)
NS_IMPL_CYCLE_COLLECTING_ADDREF(ServiceWorkerClient)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ServiceWorkerClient)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerClient)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
JSObject*
ServiceWorkerClient::WrapObject(JSContext* aCx)
{
return ServiceWorkerClientBinding::Wrap(aCx, this);
}

View File

@ -1,58 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef mozilla_dom_workers_serviceworkerclient_h
#define mozilla_dom_workers_serviceworkerclient_h
#include "nsCOMPtr.h"
#include "nsWrapperCache.h"
namespace mozilla {
namespace dom {
class Promise;
namespace workers {
class ServiceWorkerClient MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClient)
ServiceWorkerClient(nsISupports* aOwner, uint64_t aId)
: mOwner(aOwner),
mId(aId)
{
}
uint32_t Id() const
{
return mId;
}
nsISupports* GetParentObject() const
{
return mOwner;
}
JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
private:
~ServiceWorkerClient()
{
}
nsCOMPtr<nsISupports> mOwner;
uint64_t mId;
};
} // namespace workers
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_workers_serviceworkerclient_h

View File

@ -1,228 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ServiceWorkerClient.h"
#include "ServiceWorkerClients.h"
#include "ServiceWorkerManager.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ServiceWorkerClientsBinding.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::workers;
NS_IMPL_CYCLE_COLLECTING_ADDREF(ServiceWorkerClients)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ServiceWorkerClients)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ServiceWorkerClients, mWorkerScope)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerClients)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
ServiceWorkerClients::ServiceWorkerClients(ServiceWorkerGlobalScope* aWorkerScope)
: mWorkerScope(aWorkerScope)
{
MOZ_ASSERT(mWorkerScope);
}
JSObject*
ServiceWorkerClients::WrapObject(JSContext* aCx)
{
return ServiceWorkerClientsBinding::Wrap(aCx, this);
}
namespace {
// Helper class used for passing the promise between threads while
// keeping the worker alive.
class PromiseHolder MOZ_FINAL : public WorkerFeature
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PromiseHolder)
public:
PromiseHolder(WorkerPrivate* aWorkerPrivate,
Promise* aPromise)
: mWorkerPrivate(aWorkerPrivate),
mPromise(aPromise),
mClean(false)
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mPromise);
if (NS_WARN_IF(!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), this))) {
// Worker has been canceled and will go away.
// The ResolvePromiseWorkerRunnable won't run, so we can set mPromise to
// nullptr.
mPromise = nullptr;
mClean = true;
}
}
Promise*
Get() const
{
return mPromise;
}
void
Clean()
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mClean) {
return;
}
mPromise = nullptr;
mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
mClean = true;
}
bool
Notify(JSContext* aCx, Status aStatus)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (aStatus > Running) {
Clean();
}
return true;
}
private:
~PromiseHolder()
{
MOZ_ASSERT(mClean);
}
WorkerPrivate* mWorkerPrivate;
nsRefPtr<Promise> mPromise;
bool mClean;
};
class ResolvePromiseWorkerRunnable MOZ_FINAL : public WorkerRunnable
{
nsRefPtr<PromiseHolder> mPromiseHolder;
nsAutoPtr<nsTArray<uint64_t>> mValue;
public:
ResolvePromiseWorkerRunnable(WorkerPrivate* aWorkerPrivate,
PromiseHolder* aPromiseHolder,
nsAutoPtr<nsTArray<uint64_t>>& aValue)
: WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount),
mPromiseHolder(aPromiseHolder),
mValue(aValue)
{
AssertIsOnMainThread();
}
bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
{
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
Promise* promise = mPromiseHolder->Get();
MOZ_ASSERT(promise);
nsTArray<nsRefPtr<ServiceWorkerClient>> ret;
for (size_t i = 0; i < mValue->Length(); i++) {
ret.AppendElement(nsRefPtr<ServiceWorkerClient>(
new ServiceWorkerClient(promise->GetParentObject(),
mValue->ElementAt(i))));
}
promise->MaybeResolve(ret);
// release the reference on the worker thread.
mPromiseHolder->Clean();
return true;
}
};
class GetServicedRunnable MOZ_FINAL : public nsRunnable
{
WorkerPrivate* mWorkerPrivate;
nsCString mScope;
nsRefPtr<PromiseHolder> mPromiseHolder;
public:
GetServicedRunnable(WorkerPrivate* aWorkerPrivate,
Promise* aPromise,
const nsCString& aScope)
: mWorkerPrivate(aWorkerPrivate),
mScope(aScope)
{
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
mPromiseHolder = new PromiseHolder(aWorkerPrivate, aPromise);
}
NS_IMETHOD
Run() MOZ_OVERRIDE
{
AssertIsOnMainThread();
nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
nsAutoPtr<nsTArray<uint64_t>> result(new nsTArray<uint64_t>());
swm->GetServicedClients(mScope, result);
nsRefPtr<ResolvePromiseWorkerRunnable> r =
new ResolvePromiseWorkerRunnable(mWorkerPrivate, mPromiseHolder, result);
AutoSafeJSContext cx;
r->Dispatch(cx);
return NS_OK;
}
};
} // anonymous namespace
already_AddRefed<Promise>
ServiceWorkerClients::GetServiced(ErrorResult& aRv)
{
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
workerPrivate->AssertIsOnWorkerThread();
DOMString scope;
mWorkerScope->GetScope(scope);
nsRefPtr<Promise> promise = Promise::Create(mWorkerScope, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
nsRefPtr<GetServicedRunnable> r =
new GetServicedRunnable(workerPrivate, promise, NS_ConvertUTF16toUTF8(scope));
nsresult rv = NS_DispatchToMainThread(r);
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(NS_ERROR_NOT_AVAILABLE);
}
return promise.forget();
}
// FIXME(catalinb): Bug 1045257 - Implement ReloadAll
already_AddRefed<Promise>
ServiceWorkerClients::ReloadAll(ErrorResult& aRv)
{
nsRefPtr<Promise> promise = Promise::Create(mWorkerScope, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
promise->MaybeReject(NS_ERROR_NOT_AVAILABLE);
return promise.forget();
}

View File

@ -1,56 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef mozilla_dom_workers_serviceworkerclients_h
#define mozilla_dom_workers_serviceworkerclients_h
#include "nsAutoPtr.h"
#include "nsWrapperCache.h"
namespace mozilla {
class ErrorResult;
namespace dom {
class Promise;
namespace workers {
class ServiceWorkerGlobalScope;
class ServiceWorkerClients MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClients)
ServiceWorkerClients(ServiceWorkerGlobalScope* aWorkerScope);
already_AddRefed<Promise> GetServiced(ErrorResult& aRv);
already_AddRefed<Promise> ReloadAll(ErrorResult& aRv);
JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
ServiceWorkerGlobalScope* GetParentObject() const
{
return mWorkerScope;
}
private:
~ServiceWorkerClients()
{
}
nsRefPtr<ServiceWorkerGlobalScope> mWorkerScope;
};
} // namespace workers
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_workers_serviceworkerclients_h

View File

@ -24,7 +24,6 @@
#include "RuntimeService.h"
#include "ServiceWorker.h"
#include "ServiceWorkerClient.h"
#include "ServiceWorkerRegistration.h"
#include "ServiceWorkerEvents.h"
#include "WorkerInlines.h"
@ -71,7 +70,6 @@ UpdatePromise::ResolveAllPromises(const nsACString& aScriptSpec, const nsACStrin
for (uint32_t i = 0; i < array.Length(); ++i) {
WeakPtr<Promise>& pendingPromise = array.ElementAt(i);
if (pendingPromise) {
nsRefPtr<Promise> kungfuDeathGrip = pendingPromise.get();
nsCOMPtr<nsIGlobalObject> go =
do_QueryInterface(pendingPromise->GetParentObject());
MOZ_ASSERT(go);
@ -95,7 +93,8 @@ UpdatePromise::ResolveAllPromises(const nsACString& aScriptSpec, const nsACStrin
// Since ServiceWorkerRegistration is only exposed to windows we can be
// certain about this cast.
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(go);
nsCOMPtr<nsPIDOMWindow> window =
do_QueryInterface(pendingPromise->GetParentObject());
nsRefPtr<ServiceWorkerRegistration> swr =
new ServiceWorkerRegistration(window, NS_ConvertUTF8toUTF16(aScope));
@ -2142,54 +2141,4 @@ ServiceWorkerManager::InvalidateServiceWorkerRegistrationWorker(ServiceWorkerReg
}
}
namespace {
class MOZ_STACK_CLASS FilterRegistrationData
{
public:
FilterRegistrationData(nsTArray<uint64_t>* aDocuments,
ServiceWorkerRegistrationInfo* aRegistration)
: mDocuments(aDocuments),
mRegistration(aRegistration)
{
}
nsTArray<uint64_t>* mDocuments;
nsRefPtr<ServiceWorkerRegistrationInfo> mRegistration;
};
static PLDHashOperator
EnumControlledDocuments(nsISupports* aKey,
ServiceWorkerRegistrationInfo* aRegistration,
void* aData)
{
FilterRegistrationData* data = static_cast<FilterRegistrationData*>(aData);
if (data->mRegistration != aRegistration) {
return PL_DHASH_NEXT;
}
nsCOMPtr<nsIDocument> document = do_QueryInterface(aKey);
if (!document || !document->GetInnerWindow()) {
return PL_DHASH_NEXT;
}
data->mDocuments->AppendElement(document->GetInnerWindow()->WindowID());
return PL_DHASH_NEXT;
}
} // anonymous namespace
void
ServiceWorkerManager::GetServicedClients(const nsCString& aScope,
nsTArray<uint64_t>* aControlledDocuments)
{
nsRefPtr<ServiceWorkerDomainInfo> domainInfo = GetDomainInfo(aScope);
nsRefPtr<ServiceWorkerRegistrationInfo> registration =
domainInfo->GetRegistration(aScope);
MOZ_ASSERT(registration);
FilterRegistrationData data(aControlledDocuments, registration);
domainInfo->mControlledDocuments.EnumerateRead(EnumControlledDocuments,
&data);
}
END_WORKERS_NAMESPACE

View File

@ -317,10 +317,6 @@ public:
uint32_t aColumnNumber,
uint32_t aFlags);
void
GetServicedClients(const nsCString& aScope,
nsTArray<uint64_t>* aControlledDocuments);
static already_AddRefed<ServiceWorkerManager>
GetInstance();

View File

@ -359,14 +359,6 @@ SharedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx)
true);
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope,
mClients)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope)
NS_INTERFACE_MAP_END_INHERITING(WorkerGlobalScope)
NS_IMPL_ADDREF_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope)
NS_IMPL_RELEASE_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope)
ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
const nsACString& aScope)
: WorkerGlobalScope(aWorkerPrivate),

View File

@ -11,8 +11,6 @@
#include "mozilla/dom/Headers.h"
#include "mozilla/dom/RequestBinding.h"
#include "ServiceWorkerClients.h"
namespace mozilla {
namespace dom {
@ -172,15 +170,9 @@ public:
class ServiceWorkerGlobalScope MOZ_FINAL : public WorkerGlobalScope
{
const nsString mScope;
nsRefPtr<ServiceWorkerClients> mClients;
~ServiceWorkerGlobalScope() { }
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerGlobalScope,
WorkerGlobalScope)
ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate, const nsACString& aScope);
virtual JSObject*
@ -207,15 +199,6 @@ public:
already_AddRefed<Promise>
Unregister(ErrorResult& aRv);
ServiceWorkerClients*
Clients() {
if (!mClients) {
mClients = new ServiceWorkerClients(this);
}
return mClients;
}
IMPL_EVENT_HANDLER(activate)
IMPL_EVENT_HANDLER(beforeevicted)
IMPL_EVENT_HANDLER(evicted)

View File

@ -30,8 +30,6 @@ EXPORTS.mozilla.dom.workers.bindings += [
'Navigator.h',
'Performance.h',
'ServiceWorker.h',
'ServiceWorkerClient.h',
'ServiceWorkerClients.h',
'SharedWorker.h',
'URL.h',
'WorkerFeature.h',
@ -60,8 +58,6 @@ UNIFIED_SOURCES += [
'RuntimeService.cpp',
'ScriptLoader.cpp',
'ServiceWorker.cpp',
'ServiceWorkerClient.cpp',
'ServiceWorkerClients.cpp',
'ServiceWorkerContainer.cpp',
'ServiceWorkerEvents.cpp',
'ServiceWorkerManager.cpp',

View File

@ -1,16 +0,0 @@
function loop() {
self.clients.getServiced().then(function(result) {
setTimeout(loop, 0);
});
}
onactivate = function(e) {
// spam getServiced until the worker is closed.
loop();
}
onclose = function(e) {
for (var i = 0; i < 100; ++i) {
self.clients.getServiced();
}
}

View File

@ -10,10 +10,7 @@ support-files =
simpleregister/ready.html
controller/index.html
unregister/index.html
sw_clients/simple.html
get_serviced_worker.js
[test_get_serviced.html]
[test_installation_simple.html]
[test_install_event.html]
[test_navigator.html]

View File

@ -1,25 +0,0 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 982726 - test get_serviced not crashing</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">
window.onload = function() {
opener.postMessage("READY", "*");
}
</script>
</pre>
</body>
</html>

View File

@ -1,57 +0,0 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 982726 - test get_serviced not crashing</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">
// get_serviced_worker will call getServiced until the worker shuts down.
// Test passes if the browser doesn't crash on leaked promise objects.
var controlled_window;
function simpleRegister() {
return navigator.serviceWorker.register("get_serviced_worker.js", { scope: "./sw_clients/" });
}
function openWindow() {
var p = new Promise(function(resolve, reject) {
window.onmessage = function(e) {
if (e.data === "READY") {
resolve();
}
}
});
controlled_window = window.open("sw_clients/simple.html");
return p;
}
function runTest() {
simpleRegister()
.then(openWindow).catch(function(e) {
ok(false, "Some test failed with error " + e);
}).then(function() {
ok(true, "Didn't crash on resolving getServiced promises while worker shuts down.");
SimpleTest.finish();
controlled_window.close();
});
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true]
]}, runTest);
</script>
</pre>
</body>
</html>

View File

@ -16,7 +16,6 @@
<script class="testbody" type="text/javascript">
function simpleRegister() {
info("simpleRegister() just before calling register");
return navigator.serviceWorker.register("worker.js", { scope: "unregister/" });
}
@ -49,7 +48,6 @@
function unregister() {
return navigator.serviceWorker.getRegistration("unregister/")
.then(function(reg) {
info("getRegistration() succeeded " + reg.scope);
return reg.unregister().then(function(v) {
ok(v, "Unregister should resolve to true");
}, function(e) {
@ -86,25 +84,9 @@
function runTest() {
simpleRegister()
.then(function(v) {
info("simpleRegister() promise resolved");
})
.then(testControlled)
.then(function(v) {
info("testControlled() promise resolved");
}, function(e) {
info("testControlled() promise rejected " + e);
})
.then(unregister)
.then(function(v) {
info("unregister() promise resolved");
})
.then(testUncontrolled)
.then(function(v) {
info("testUncontrolled() promise resolved");
}, function(e) {
info("testUncontrolled() promise rejected " + e);
})
.then(function() {
SimpleTest.finish();
}).catch(function(e) {

View File

@ -20,21 +20,17 @@
}
var tId = setTimeout(function() {
info("tId timeout!");
parent.postMessage({ controlled: false }, "*");
tId = null;
}, 2000);
navigator.serviceWorker.ready.then(function() {
info("Got ready");
if (tId == null) {
info("tId was null");
parent.postMessage("FAIL!!!", "*");
return;
}
clearTimeout(tId);
info("tId was non-null");
parent.postMessage({ controlled: true }, "*");
});