зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1181037 - Use entry settings object's base URL. r=ehsan
The second test, which checks for NetworkError is incorrect. [[Update]] step 12 states: "If response is a network error or response's status is not in the range 200 to 299, then: 1. Reject p with a TypeError." which specifically converts the NetworkError (due to 404) to a TypeError. Also fixes controller-on-reload.https.html Update web-platform-tests expected data --HG-- extra : commitid : LUdPR44iiv2 extra : rebase_source : 6774faa1417ce585161750f14bf233d7382bea68
This commit is contained in:
Родитель
af3e91f01a
Коммит
5cf1847cde
|
@ -113,13 +113,32 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = GetOwner();
|
||||
MOZ_ASSERT(window);
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
|
||||
nsIDocument* doc = GetEntryDocument();
|
||||
if (doc) {
|
||||
baseURI = doc->GetBaseURI();
|
||||
} else {
|
||||
// XXXnsm. One of our devtools browser test calls register() from a content
|
||||
// script where there is no valid entry document. Use the window to resolve
|
||||
// the uri in that case.
|
||||
nsCOMPtr<nsPIDOMWindow> window = GetOwner();
|
||||
nsCOMPtr<nsPIDOMWindow> outerWindow;
|
||||
if (window && (outerWindow = window->GetOuterWindow()) &&
|
||||
outerWindow->GetServiceWorkersTestingEnabled()) {
|
||||
baseURI = window->GetDocBaseURI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!baseURI) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> scriptURI;
|
||||
rv = NS_NewURI(getter_AddRefs(scriptURI), aScriptURL, nullptr,
|
||||
window->GetDocBaseURI());
|
||||
rv = NS_NewURI(getter_AddRefs(scriptURI), aScriptURL, nullptr, baseURI);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_URL, &aScriptURL);
|
||||
return nullptr;
|
||||
|
@ -143,17 +162,19 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
|||
} else {
|
||||
// Step 5. Parse against entry settings object's base URL.
|
||||
rv = NS_NewURI(getter_AddRefs(scopeURI), aOptions.mScope.Value(),
|
||||
nullptr, window->GetDocBaseURI());
|
||||
nullptr, baseURI);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
nsAutoCString spec;
|
||||
if (window->GetDocBaseURI()) {
|
||||
window->GetDocBaseURI()->GetSpec(spec);
|
||||
}
|
||||
baseURI->GetSpec(spec);
|
||||
aRv.ThrowTypeError(MSG_INVALID_SCOPE, &aOptions.mScope.Value(), &spec);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// The spec says that the "client" passed to Register() must be the global
|
||||
// where the ServiceWorkerContainer was retrieved from.
|
||||
nsCOMPtr<nsPIDOMWindow> window = GetOwner();
|
||||
MOZ_ASSERT(window);
|
||||
aRv = swm->Register(window, scopeURI, scriptURI, getter_AddRefs(promise));
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[controller-on-reload.https.html]
|
||||
type: testharness
|
||||
[controller is set upon reload after registration]
|
||||
expected: FAIL
|
||||
|
|
@ -3,3 +3,4 @@
|
|||
expected: OK
|
||||
[Calling respondWith asynchronously throws an exception]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
[registration-iframe.https.html]
|
||||
type: testharness
|
||||
[Subframe's container's register method should use calling frame's document's url as a base url for parsing its script url and scope url - normal case]
|
||||
expected: FAIL
|
||||
|
||||
[Subframe's container's register method should use calling frame's document's url as a base url for parsing its script url and scope url - error case]
|
||||
expected: FAIL
|
||||
|
||||
[A scope url should start with the given script url]
|
||||
expected: FAIL
|
||||
|
|
@ -68,7 +68,7 @@ async_test(function(t) {
|
|||
assert_unreached('register() should reject');
|
||||
},
|
||||
function(e) {
|
||||
assert_equals(e.name, 'NetworkError');
|
||||
assert_equals(e.name, 'TypeError');
|
||||
frame.remove();
|
||||
return service_worker_unregister_and_done(t, scope);
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче