mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1132924 - XHR should support empty response in workers, r=bkelly. r=bent
This commit is contained in:
parent
1b6561194e
commit
0a194e5205
@ -2382,19 +2382,24 @@ XMLHttpRequest::GetResponse(JSContext* /* unused */,
|
||||
{
|
||||
if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
|
||||
mStateData.mResponse.isUndefined()) {
|
||||
MOZ_ASSERT(mStateData.mResponseText.Length());
|
||||
MOZ_ASSERT(NS_SUCCEEDED(mStateData.mResponseResult));
|
||||
|
||||
JSString* str =
|
||||
JS_NewUCStringCopyN(mWorkerPrivate->GetJSContext(),
|
||||
mStateData.mResponseText.get(),
|
||||
mStateData.mResponseText.Length());
|
||||
if (!str) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
if (mStateData.mResponseText.IsEmpty()) {
|
||||
mStateData.mResponse =
|
||||
JS_GetEmptyStringValue(mWorkerPrivate->GetJSContext());
|
||||
} else {
|
||||
JSString* str =
|
||||
JS_NewUCStringCopyN(mWorkerPrivate->GetJSContext(),
|
||||
mStateData.mResponseText.get(),
|
||||
mStateData.mResponseText.Length());
|
||||
|
||||
mStateData.mResponse = STRING_TO_JSVAL(str);
|
||||
if (!str) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
||||
mStateData.mResponse = STRING_TO_JSVAL(str);
|
||||
}
|
||||
}
|
||||
|
||||
JS::ExposeValueToActiveJS(mStateData.mResponse);
|
||||
|
10
dom/workers/test/bug1132924_worker.js
Normal file
10
dom/workers/test/bug1132924_worker.js
Normal file
@ -0,0 +1,10 @@
|
||||
onmessage = function() {
|
||||
var a = new XMLHttpRequest();
|
||||
a.open('GET', 'empty.html', false);
|
||||
a.onreadystatechange = function() {
|
||||
if (a.readyState == 4) {
|
||||
postMessage(a.response);
|
||||
}
|
||||
}
|
||||
a.send(null);
|
||||
}
|
0
dom/workers/test/empty.html
Normal file
0
dom/workers/test/empty.html
Normal file
@ -99,6 +99,8 @@ support-files =
|
||||
bug1104064_worker.js
|
||||
worker_consoleAndBlobs.js
|
||||
bug1132395_sharedWorker.js
|
||||
bug1132924_worker.js
|
||||
empty.html
|
||||
|
||||
[test_404.html]
|
||||
[test_atob.html]
|
||||
@ -201,3 +203,4 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 982828
|
||||
[test_bug1104064.html]
|
||||
[test_consoleAndBlobs.html]
|
||||
[test_bug1132395.html]
|
||||
[test_bug1132924.html]
|
||||
|
28
dom/workers/test/test_bug1132924.html
Normal file
28
dom/workers/test/test_bug1132924.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for 1132924</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var w = new Worker('bug1132924_worker.js');
|
||||
w.onmessage = function(event) {
|
||||
ok(true, "We are still alive.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
w.postMessage('go');
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user