importScripts_mixedcontent.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <!DOCTYPE html>
  6. <script>
  7. function ok(cond, msg) {
  8. window.parent.postMessage({status: "ok", data: cond, msg: msg}, "*");
  9. }
  10. function finish() {
  11. window.parent.postMessage({status: "done"}, "*");
  12. }
  13. function testSharedWorker() {
  14. var sw = new SharedWorker("importForeignScripts_worker.js");
  15. sw.port.onmessage = function(e) {
  16. if (e.data == "finish") {
  17. finish();
  18. return;
  19. }
  20. ok(e.data === "good", "mixed content for shared workers is correctly blocked");
  21. };
  22. sw.onerror = function() {
  23. ok(false, "Error on shared worker ");
  24. };
  25. sw.port.postMessage("start");
  26. }
  27. var worker = new Worker("importForeignScripts_worker.js");
  28. worker.onmessage = function(e) {
  29. if (e.data == "finish") {
  30. testSharedWorker();
  31. return;
  32. }
  33. ok(e.data === "good", "mixed content is correctly blocked");
  34. }
  35. worker.onerror = function() {
  36. ok(false, "Error on worker");
  37. }
  38. worker.postMessage("start");
  39. </script>