mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
Backed out changeset f447f7b8190b (bug 1185640) for W8 failures on CLOSED TREE
--HG-- extra : amend_source : 1fca18be89fda404fb71c3f0c8550011ded2d7de
This commit is contained in:
parent
68c09ac436
commit
d78ab7197e
@ -1696,12 +1696,16 @@ public:
|
||||
|
||||
/**
|
||||
* Convert ASCII A-Z to a-z.
|
||||
* @return NS_OK on success, or NS_ERROR_OUT_OF_MEMORY if making the string
|
||||
* writable needs to allocate memory and that allocation fails.
|
||||
*/
|
||||
static void ASCIIToLower(nsAString& aStr);
|
||||
static void ASCIIToLower(const nsAString& aSource, nsAString& aDest);
|
||||
|
||||
/**
|
||||
* Convert ASCII a-z to A-Z.
|
||||
* @return NS_OK on success, or NS_ERROR_OUT_OF_MEMORY if making the string
|
||||
* writable needs to allocate memory and that allocation fails.
|
||||
*/
|
||||
static void ASCIIToUpper(nsAString& aStr);
|
||||
static void ASCIIToUpper(const nsAString& aSource, nsAString& aDest);
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIServiceWorkerManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -101,31 +100,6 @@ ServiceWorkerContainer::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenP
|
||||
return ServiceWorkerContainerBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
CheckForSlashEscapedCharsInPath(nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(aURI));
|
||||
if (NS_WARN_IF(!url)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoCString path;
|
||||
nsresult rv = url->GetFilePath(path);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (path.Find("%2f", true /* ignore case */) != kNotFound ||
|
||||
path.Find("%5c", true /* ignore case */) != kNotFound) {
|
||||
return NS_ERROR_DOM_TYPE_ERR;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
||||
const RegistrationOptions& aOptions,
|
||||
@ -151,11 +125,6 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aRv = CheckForSlashEscapedCharsInPath(scriptURI);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// In ServiceWorkerContainer.register() the scope argument is parsed against
|
||||
// different base URLs depending on whether it was passed or not.
|
||||
nsCOMPtr<nsIURI> scopeURI;
|
||||
@ -183,11 +152,6 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
|
||||
aRv.ThrowTypeError(MSG_INVALID_SCOPE, &aOptions.mScope.Value(), &spec);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aRv = CheckForSlashEscapedCharsInPath(scopeURI);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
aRv = swm->Register(window, scopeURI, scriptURI, getter_AddRefs(promise));
|
||||
|
@ -244,4 +244,3 @@ skip-if = toolkit == "android" || toolkit == "gonk"
|
||||
[test_workerupdatefoundevent.html]
|
||||
[test_opaque_intercept.html]
|
||||
[test_fetch_event_client_postmessage.html]
|
||||
[test_escapedSlashes.html]
|
||||
|
@ -1,111 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for escaped slashes in navigator.serviceWorker.register</title>
|
||||
<script type="text/javascript" src="http://mochi.test:8888/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="http://mochi.test:8888/tests/SimpleTest/test.css" />
|
||||
<base href="https://mozilla.org/">
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test"></pre>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var tests = [
|
||||
{ status: true,
|
||||
scriptURL: "a.js?foo%2fbar",
|
||||
scopeURL: null },
|
||||
{ status: true,
|
||||
scriptURL: "a.js#foo%2fbar",
|
||||
scopeURL: null },
|
||||
{ status: false,
|
||||
scriptURL: "foo%2fbar",
|
||||
scopeURL: null },
|
||||
{ status: true,
|
||||
scriptURL: "a.js?foo%2Fbar",
|
||||
scopeURL: null },
|
||||
{ status: false,
|
||||
scriptURL: "foo%2Fbar",
|
||||
scopeURL: null },
|
||||
{ status: true,
|
||||
scriptURL: "a.js?foo%5cbar",
|
||||
scopeURL: null },
|
||||
{ status: false,
|
||||
scriptURL: "foo%5cbar",
|
||||
scopeURL: null },
|
||||
{ status: true,
|
||||
scriptURL: "a.js?foo%2Cbar",
|
||||
scopeURL: null },
|
||||
{ status: false,
|
||||
scriptURL: "foo%5Cbar",
|
||||
scopeURL: null },
|
||||
{ status: true,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "/scope?foo%2fbar"},
|
||||
{ status: true,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "/scope#foo%2fbar"},
|
||||
{ status: false,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "/foo%2fbar"},
|
||||
{ status: true,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "/scope?foo%2Fbar"},
|
||||
{ status: false,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "foo%2Fbar"},
|
||||
{ status: true,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "/scope?foo%5cbar"},
|
||||
{ status: false,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "foo%5cbar"},
|
||||
{ status: true,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "/scope?foo%5Cbar"},
|
||||
{ status: true,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "/scope#foo%5Cbar"},
|
||||
{ status: false,
|
||||
scriptURL: "ok.js",
|
||||
scopeURL: "foo%5Cbar"},
|
||||
];
|
||||
|
||||
function runTest() {
|
||||
if (!tests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var test = tests.shift();
|
||||
navigator.serviceWorker.register(test.scriptURL, test.scopeURL)
|
||||
.then(reg => {
|
||||
ok(false, "Register should fail");
|
||||
}, err => {
|
||||
if (!test.status) {
|
||||
is(err.name, "TypeError", "Registration should fail with TypeError");
|
||||
} else {
|
||||
ok(test.status, "Register should fail");
|
||||
}
|
||||
})
|
||||
.then(runTest);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
onload = function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
]}, runTest);
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user