Bug 1025082 - ServiceWorker related WebIDL changes. r=ehsan,jst

This commit is contained in:
Nikhil Marathe
2014-06-17 11:01:28 -07:00
parent 438237ecfc
commit f232e45ba5
7 changed files with 35 additions and 24 deletions

View File

@@ -1945,8 +1945,8 @@ GK_ATOM(onratechange, "onratechange")
GK_ATOM(ondurationchange, "ondurationchange") GK_ATOM(ondurationchange, "ondurationchange")
GK_ATOM(onvolumechange, "onvolumechange") GK_ATOM(onvolumechange, "onvolumechange")
GK_ATOM(onaddtrack, "onaddtrack") GK_ATOM(onaddtrack, "onaddtrack")
GK_ATOM(oncontrollerchange, "oncontrollerchange")
GK_ATOM(oncuechange, "oncuechange") GK_ATOM(oncuechange, "oncuechange")
GK_ATOM(oncurrentchange, "oncurrentchange")
GK_ATOM(onenter, "onenter") GK_ATOM(onenter, "onenter")
GK_ATOM(onexit, "onexit") GK_ATOM(onexit, "onexit")
GK_ATOM(onneedkey, "onneedkey") GK_ATOM(onneedkey, "onneedkey")

View File

@@ -22,7 +22,6 @@ interface ServiceWorker : EventTarget {
ServiceWorker implements AbstractWorker; ServiceWorker implements AbstractWorker;
enum ServiceWorkerState { enum ServiceWorkerState {
"parsed",
"installing", "installing",
"installed", "installed",
"activating", "activating",

View File

@@ -15,23 +15,26 @@ interface ServiceWorkerContainer {
// and discussion at https://etherpad.mozilla.org/serviceworker07apr // and discussion at https://etherpad.mozilla.org/serviceworker07apr
[Unforgeable] readonly attribute ServiceWorker? installing; [Unforgeable] readonly attribute ServiceWorker? installing;
[Unforgeable] readonly attribute ServiceWorker? waiting; [Unforgeable] readonly attribute ServiceWorker? waiting;
[Unforgeable] readonly attribute ServiceWorker? current; [Unforgeable] readonly attribute ServiceWorker? active;
[Unforgeable] readonly attribute ServiceWorker? controller;
// Promise<ServiceWorker>
readonly attribute Promise ready;
// Promise<sequence<ServiceWorker>?>
[Throws] [Throws]
Promise getAll(); Promise getAll();
// Promise<ServiceWorker>
[Throws] [Throws]
Promise register(DOMString url, optional RegistrationOptionList options); Promise register(DOMString url, optional RegistrationOptionList options);
// Promise<any>
[Throws] [Throws]
Promise unregister(DOMString? scope); Promise unregister(DOMString? scope);
// Promise<ServiceWorker>
[Throws]
Promise whenReady();
attribute EventHandler onupdatefound; attribute EventHandler onupdatefound;
attribute EventHandler oncurrentchange; attribute EventHandler oncontrollerchange;
attribute EventHandler onreloadpage; attribute EventHandler onreloadpage;
attribute EventHandler onerror; attribute EventHandler onerror;
}; };
@@ -46,5 +49,5 @@ partial interface ServiceWorkerContainer {
}; };
dictionary RegistrationOptionList { dictionary RegistrationOptionList {
DOMString scope = "*"; DOMString scope = "/*";
}; };

View File

@@ -2100,9 +2100,6 @@ RuntimeService::CreateServiceWorker(const GlobalObject& aGlobal,
nsRefPtr<ServiceWorker> serviceWorker = nsRefPtr<ServiceWorker> serviceWorker =
new ServiceWorker(window, sharedWorker); new ServiceWorker(window, sharedWorker);
// While it hasn't been parsed, the intention is to only expose ServiceWorkers
// to content after it has indeed been parsed.
serviceWorker->mState = ServiceWorkerState::Parsed;
serviceWorker->mURL = aScriptURL; serviceWorker->mURL = aScriptURL;
serviceWorker->mScope = NS_ConvertUTF8toUTF16(aScope); serviceWorker->mScope = NS_ConvertUTF8toUTF16(aScope);

View File

@@ -97,7 +97,14 @@ ServiceWorkerContainer::GetWaiting()
} }
already_AddRefed<workers::ServiceWorker> already_AddRefed<workers::ServiceWorker>
ServiceWorkerContainer::GetCurrent() ServiceWorkerContainer::GetActive()
{
// FIXME(nsm): Bug 1002570
return nullptr;
}
already_AddRefed<workers::ServiceWorker>
ServiceWorkerContainer::GetController()
{ {
// FIXME(nsm): Bug 1002570 // FIXME(nsm): Bug 1002570
return nullptr; return nullptr;
@@ -112,11 +119,12 @@ ServiceWorkerContainer::GetAll(ErrorResult& aRv)
} }
already_AddRefed<Promise> already_AddRefed<Promise>
ServiceWorkerContainer::WhenReady(ErrorResult& aRv) ServiceWorkerContainer::Ready()
{ {
// FIXME(nsm): Bug 984048 // FIXME(nsm): Bug 1025077
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
return nullptr; nsRefPtr<Promise> promise = new Promise(global);
return promise.forget();
} }
// Testing only. // Testing only.

View File

@@ -29,7 +29,7 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerContainer, DOMEventTargetHelper) NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerContainer, DOMEventTargetHelper)
IMPL_EVENT_HANDLER(updatefound) IMPL_EVENT_HANDLER(updatefound)
IMPL_EVENT_HANDLER(currentchange) IMPL_EVENT_HANDLER(controllerchange)
IMPL_EVENT_HANDLER(reloadpage) IMPL_EVENT_HANDLER(reloadpage)
IMPL_EVENT_HANDLER(error) IMPL_EVENT_HANDLER(error)
@@ -64,13 +64,16 @@ public:
GetWaiting(); GetWaiting();
already_AddRefed<ServiceWorker> already_AddRefed<ServiceWorker>
GetCurrent(); GetActive();
already_AddRefed<ServiceWorker>
GetController();
already_AddRefed<Promise> already_AddRefed<Promise>
GetAll(ErrorResult& aRv); GetAll(ErrorResult& aRv);
already_AddRefed<Promise> already_AddRefed<Promise>
WhenReady(ErrorResult& aRv); Ready();
// Testing only. // Testing only.
already_AddRefed<Promise> already_AddRefed<Promise>

View File

@@ -20,10 +20,11 @@
ok(typeof navigator.serviceWorker.register === "function", "navigator.serviceWorker.register() should be a function."); ok(typeof navigator.serviceWorker.register === "function", "navigator.serviceWorker.register() should be a function.");
ok(typeof navigator.serviceWorker.unregister === "function", "navigator.serviceWorker.unregister() should be a function."); ok(typeof navigator.serviceWorker.unregister === "function", "navigator.serviceWorker.unregister() should be a function.");
ok(typeof navigator.serviceWorker.getAll === "function", "navigator.serviceWorker.getAll() should be a function."); ok(typeof navigator.serviceWorker.getAll === "function", "navigator.serviceWorker.getAll() should be a function.");
ok(typeof navigator.serviceWorker.whenReady === "function", "navigator.serviceWorker.whenReady() should be a function."); ok(navigator.serviceWorker.ready instanceof Promise, "navigator.serviceWorker.ready should be a Promise.");
ok(navigator.serviceWorker.installing === null, "There should be no installing worker for an uncontrolled document."); ok(navigator.serviceWorker.installing === null, "There should be no installing worker for an uncontrolled scope.");
ok(navigator.serviceWorker.waiting === null, "There should be no waiting worker for an uncontrolled document."); ok(navigator.serviceWorker.waiting === null, "There should be no waiting worker for an uncontrolled scope.");
ok(navigator.serviceWorker.current === null, "There should be no current worker for an uncontrolled document."); ok(navigator.serviceWorker.active === null, "There should be no active worker for an uncontrolled scope.");
ok(navigator.serviceWorker.controller === null, "There should be no active worker for an uncontrolled document.");
} }
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();