Bug 788181. Fix instanceof for XHR and XHR.upload in workers. r=peterv

This commit is contained in:
Andrea Marchesini 2012-09-05 13:37:27 -04:00
Родитель 65e4105d26
Коммит 462c20197a
4 изменённых файлов: 61 добавлений и 5 удалений

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

@ -984,11 +984,13 @@ CreateDedicatedWorkerGlobalScope(JSContext* aCx)
return NULL;
}
// Init other paris-bindings.
if (!XMLHttpRequestBinding_workers::CreateInterfaceObjects(aCx, global,
global) ||
!XMLHttpRequestUploadBinding_workers::CreateInterfaceObjects(aCx, global,
global)) {
// Init other paris-bindings. Use GetProtoObject so the proto will
// be correctly cached in the proto cache. Otherwise we'll end up
// double-calling CreateInterfaceObjects when we actually create an
// object which has these protos, which breaks things like
// instanceof.
if (!XMLHttpRequestBinding_workers::GetProtoObject(aCx, global, global) ||
!XMLHttpRequestUploadBinding_workers::GetProtoObject(aCx, global, global)) {
return NULL;
}

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

@ -39,6 +39,8 @@ MOCHITEST_FILES = \
importScripts_worker_imported2.js \
importScripts_worker_imported3.js \
importScripts_worker_imported4.js \
test_instanceof.html \
instanceof_worker.js \
test_json.html \
json_worker.js \
test_location.html \

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

@ -0,0 +1,12 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
onmessage = function(event) {
postMessage({event: "XMLHttpRequest",
status: (new XMLHttpRequest() instanceof XMLHttpRequest),
last: false });
postMessage({event: "XMLHttpRequestUpload",
status: ((new XMLHttpRequest()).upload instanceof XMLHttpRequestUpload),
last: true });
}

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

@ -0,0 +1,40 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<!--
Tests of DOM Worker JSON messages
-->
<head>
<title>Test for DOM Worker Navigator</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script src="json_worker.js" language="javascript"></script>
<script class="testbody" language="javascript">
var worker = new Worker("instanceof_worker.js");
worker.onmessage = function(event) {
ok(event.data.status, event.data.event);
if (event.data.last)
SimpleTest.finish();
};
worker.postMessage(42);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>