Bug 1190703 - Relax scope resolution assertion in ServiceWorkerContainer::Register. r=bkelly

--HG--
extra : commitid : 2VyBa3KOyIV
extra : rebase_source : 81940c62d45ce34df1ce60f33ac90f762acee937
extra : amend_source : d0c955ca481b3a473d698176fea9aed407443ff4
This commit is contained in:
Nikhil Marathe 2015-08-05 14:33:50 -07:00
Родитель 65fb80c877
Коммит 0d07229d06
2 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -76,3 +76,4 @@ MSG_DEF(MSG_BAD_FORMDATA, 0, JSEXN_TYPEERR, "Could not parse content as FormData
MSG_DEF(MSG_NO_ACTIVE_WORKER, 1, JSEXN_TYPEERR, "No active worker for scope {0}.")
MSG_DEF(MSG_NOTIFICATION_PERMISSION_DENIED, 0, JSEXN_TYPEERR, "Permission to show Notification denied.")
MSG_DEF(MSG_NOTIFICATION_NO_CONSTRUCTOR_IN_SERVICEWORKER, 0, JSEXN_TYPEERR, "Notification constructor cannot be used in ServiceWorkerGlobalScope. Use registration.showNotification() instead.")
MSG_DEF(MSG_INVALID_SCOPE, 2, JSEXN_TYPEERR, "Invalid scope trying to resolve {0} with base URL {1}.")

Просмотреть файл

@ -131,15 +131,25 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
// Step 4. If none passed, parse against script's URL
if (!aOptions.mScope.WasPassed()) {
nsresult rv = NS_NewURI(getter_AddRefs(scopeURI), NS_LITERAL_CSTRING("./"),
nullptr, scriptURI);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv));
NS_NAMED_LITERAL_STRING(defaultScope, "./");
rv = NS_NewURI(getter_AddRefs(scopeURI), defaultScope,
nullptr, scriptURI);
if (NS_WARN_IF(NS_FAILED(rv))) {
nsAutoCString spec;
scriptURI->GetSpec(spec);
aRv.ThrowTypeError(MSG_INVALID_SCOPE, &defaultScope, &spec);
return nullptr;
}
} else {
// Step 5. Parse against entry settings object's base URL.
nsresult rv = NS_NewURI(getter_AddRefs(scopeURI), aOptions.mScope.Value(),
nullptr, window->GetDocBaseURI());
rv = NS_NewURI(getter_AddRefs(scopeURI), aOptions.mScope.Value(),
nullptr, window->GetDocBaseURI());
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.ThrowTypeError(MSG_INVALID_URL, &aOptions.mScope.Value());
nsAutoCString spec;
if (window->GetDocBaseURI()) {
window->GetDocBaseURI()->GetSpec(spec);
}
aRv.ThrowTypeError(MSG_INVALID_SCOPE, &aOptions.mScope.Value(), &spec);
return nullptr;
}
}