diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index dc7482aa41f9..807bbd26f250 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -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; } diff --git a/dom/workers/test/Makefile.in b/dom/workers/test/Makefile.in index 157cd5b37c90..b1a3f3e559a3 100644 --- a/dom/workers/test/Makefile.in +++ b/dom/workers/test/Makefile.in @@ -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 \ diff --git a/dom/workers/test/instanceof_worker.js b/dom/workers/test/instanceof_worker.js new file mode 100644 index 000000000000..a98255388f75 --- /dev/null +++ b/dom/workers/test/instanceof_worker.js @@ -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 }); +} diff --git a/dom/workers/test/test_instanceof.html b/dom/workers/test/test_instanceof.html new file mode 100644 index 000000000000..f73b3b6a71bb --- /dev/null +++ b/dom/workers/test/test_instanceof.html @@ -0,0 +1,40 @@ + + + + + + Test for DOM Worker Navigator + + + + +

+ +
+
+
+
+ +