зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a2f86092c968 (bug 1661174) for causing wpt failures in share-url-invalid.https.html
CLOSED TREE
This commit is contained in:
Родитель
2e43581c73
Коммит
79a31b4702
|
@ -1417,18 +1417,6 @@ Promise* Navigator::Share(const ShareData& aData, ErrorResult& aRv) {
|
|||
return nullptr;
|
||||
}
|
||||
url = result.unwrap();
|
||||
// Check that we only share loadable URLs (e.g., http/https).
|
||||
// we also exclude blobs, as it doesn't make sense to share those outside
|
||||
// the context of the browser.
|
||||
auto principal = doc->NodePrincipal();
|
||||
if (principal) {
|
||||
if (NS_FAILED(principal->CheckMayLoad(url, false)) ||
|
||||
url->SchemeIs("blob")) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>("Share",
|
||||
url->GetSpecOrDefault());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process the title member...
|
||||
|
|
|
@ -11,60 +11,15 @@
|
|||
<body>
|
||||
<script>
|
||||
promise_test(async t => {
|
||||
await test_driver.bless();
|
||||
const promise = navigator.share({ url: "http://a.com:65536" });
|
||||
return promise_rejects_js(t, TypeError, promise);
|
||||
}, "share() rejects when URL is invalid");
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.bless();
|
||||
const promise = navigator.share({ url: "file:///etc/passwd" });
|
||||
return promise_rejects_js(t, TypeError, promise);
|
||||
}, "share() rejects file:// URLs");
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.bless();
|
||||
const promise = navigator.share({ url: "wss://a.com/" });
|
||||
return promise_rejects_js(t, TypeError, promise);
|
||||
}, "share() rejects wss: URLs");
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.bless();
|
||||
const promise = navigator.share({ url: "about:config" });
|
||||
return promise_rejects_js(t, TypeError, promise);
|
||||
}, "share() rejects about: URLs");
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.bless();
|
||||
const promise = navigator.share({ url: "chrome://about" });
|
||||
return promise_rejects_js(t, TypeError, promise);
|
||||
}, "share() rejects chrome: URLs");
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.bless();
|
||||
const file = new File([], "text/plain");
|
||||
const promise = navigator.share({ url: URL.createObjectURL(file) });
|
||||
return promise_rejects_js(t, TypeError, promise);
|
||||
}, "share() rejects blob: URLs");
|
||||
|
||||
promise_test(async t => {
|
||||
const encoder = new TextEncoder();
|
||||
const encoded = encoder.encode(
|
||||
`<meta http-equiv="refresh" content="1;url=http://example.com/">`
|
||||
const url = "http://example.com:65536";
|
||||
await test_driver.bless(
|
||||
"web share",
|
||||
() => {
|
||||
return promise_rejects_js(t, TypeError, navigator.share({ url }));
|
||||
},
|
||||
"share with an invalid URL"
|
||||
);
|
||||
const file = new File(encoded, "text/html");
|
||||
const url = URL.createObjectURL(file);
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
const dataURL = await new Promise(resolve => {
|
||||
reader.addEventListener("load", () => {
|
||||
resolve(reader.result);
|
||||
});
|
||||
});
|
||||
await test_driver.bless();
|
||||
const promise = navigator.share({ url: dataURL });
|
||||
return promise_rejects_js(t, TypeError, promise);
|
||||
}, "share() rejects data: URLs");
|
||||
}, "share() rejects when URL is invalid");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче