Bug 1502599: XHR should allow just "GET" method for blob URLs, r=smaug

This commit is contained in:
Andrea Marchesini 2018-10-30 22:07:32 +01:00
Родитель 9fc151a441
Коммит 263f4c6e8b
7 изменённых файлов: 16 добавлений и 75 удалений

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

@ -196,6 +196,7 @@ scheme=https
[test_subworkers_suspended.html]
skip-if = toolkit == 'android' #bug 1366501
[test_bug1317725.html]
support-files = test_bug1317725.js
[test_sharedworker_event_listener_leaks.html]
skip-if = (bits == 64 && os == 'linux' && asan && !debug) # Disabled on Linux64 opt asan, bug 1493563
[test_fileReaderSync_when_closing.html]

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

@ -13,17 +13,6 @@
<input type="file" id="file" />
<script type="text/js-worker" id="worker-src">
onmessage = function(e) {
var data = new FormData();
data.append('Filedata', e.data.slice(0, 127), encodeURI(e.data.name));
var xhr = new XMLHttpRequest();
xhr.open('POST', location.href, false);
xhr.send(data);
postMessage("No crash \\o/");
}
</script>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
@ -35,9 +24,7 @@ function onOpened(message) {
var input = document.getElementById('file');
SpecialPowers.wrap(input).mozSetFileArray([message.data]);
var blob = new Blob([ document.getElementById("worker-src").textContent ],
{ type: "text/javascript" });
var worker = new Worker(URL.createObjectURL(blob));
var worker = new Worker("test_bug1317725.js");
worker.onerror = function(e) {
ok(false, "We should not see any error.");
SimpleTest.finish();

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

@ -0,0 +1,8 @@
onmessage = function(e) {
var data = new FormData();
data.append('Filedata', e.data.slice(0, 127), encodeURI(e.data.name));
var xhr = new XMLHttpRequest();
xhr.open('POST', location.href, false);
xhr.send(data);
postMessage("No crash \\o/");
}

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

@ -2883,6 +2883,12 @@ XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody,
return MaybeSilentSendFailure(NS_ERROR_DOM_NETWORK_ERR);
}
// non-GET requests aren't allowed for blob.
if (IsBlobURI(mRequestURL) && !mRequestMethod.EqualsLiteral("GET")) {
mFlagSend = true; // so CloseRequestWithError sets us to DONE.
return MaybeSilentSendFailure(NS_ERROR_DOM_NETWORK_ERR);
}
// XXX We should probably send a warning to the JS console
// if there are no event listeners set and we are doing
// an asynchronous call.

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

@ -1298,13 +1298,6 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
XMLHttpRequestWorker* xhr = mProxy->mXMLHttpRequestPrivate;
xhr->UpdateState(*state.get(), mUseCachedArrayBufferResponse);
if (mType.EqualsASCII(sEventStrings[STRING_readystatechange])) {
if (mReadyState == 4 && !mUploadEvent && !mProxy->mSeenLoadStart) {
// We've already dispatched premature abort events.
return true;
}
}
if (mUploadEvent && !xhr->GetUploadObjectNoCreate()) {
return true;
}

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

@ -12,24 +12,6 @@
[Appending a query string should cause XHR to fail]
expected: FAIL
[XHR with method "HEAD" should fail]
expected: FAIL
[XHR with method "POST" should fail]
expected: FAIL
[XHR with method "DELETE" should fail]
expected: FAIL
[XHR with method "OPTIONS" should fail]
expected: FAIL
[XHR with method "PUT" should fail]
expected: FAIL
[XHR with method "CUSTOM" should fail]
expected: FAIL
[Only exact matches should revoke URLs, using fetch]
expected: FAIL

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

@ -5,24 +5,6 @@
[Appending a query string should cause XHR to fail]
expected: FAIL
[XHR with method "HEAD" should fail]
expected: FAIL
[XHR with method "POST" should fail]
expected: FAIL
[XHR with method "DELETE" should fail]
expected: FAIL
[XHR with method "OPTIONS" should fail]
expected: FAIL
[XHR with method "PUT" should fail]
expected: FAIL
[XHR with method "CUSTOM" should fail]
expected: FAIL
[url-with-xhr.any.html]
[Only exact matches should revoke URLs, using XHR]
@ -31,21 +13,3 @@
[Appending a query string should cause XHR to fail]
expected: FAIL
[XHR with method "HEAD" should fail]
expected: FAIL
[XHR with method "POST" should fail]
expected: FAIL
[XHR with method "DELETE" should fail]
expected: FAIL
[XHR with method "OPTIONS" should fail]
expected: FAIL
[XHR with method "PUT" should fail]
expected: FAIL
[XHR with method "CUSTOM" should fail]
expected: FAIL