Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <!-- |
michael@0 | 3 | Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 5 | --> |
michael@0 | 6 | <window title="DOM Worker Threads Test" |
michael@0 | 7 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 8 | onload="test();"> |
michael@0 | 9 | |
michael@0 | 10 | <script type="application/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 12 | <script type="application/javascript" |
michael@0 | 13 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 14 | <script type="application/javascript" src="dom_worker_helper.js"/> |
michael@0 | 15 | |
michael@0 | 16 | <script type="application/javascript"> |
michael@0 | 17 | <![CDATA[ |
michael@0 | 18 | |
michael@0 | 19 | const Cc = Components.classes; |
michael@0 | 20 | const Ci = Components.interfaces; |
michael@0 | 21 | const Cu = Components.utils; |
michael@0 | 22 | |
michael@0 | 23 | Cu.import("resource://gre/modules/AddonManager.jsm"); |
michael@0 | 24 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 25 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 26 | |
michael@0 | 27 | function test() { |
michael@0 | 28 | const message = "woohoo"; |
michael@0 | 29 | |
michael@0 | 30 | var observer = { |
michael@0 | 31 | observe: function(subject, topic, data) { |
michael@0 | 32 | is(topic, "message", "Correct type of event"); |
michael@0 | 33 | is(data, message, "Correct message"); |
michael@0 | 34 | |
michael@0 | 35 | AddonManager.getAddonByID("workerbootstrap-test@mozilla.org", |
michael@0 | 36 | function(addon) { |
michael@0 | 37 | addon.uninstall(); |
michael@0 | 38 | |
michael@0 | 39 | const stages = [ "install", "startup", "shutdown", "uninstall" ]; |
michael@0 | 40 | const symbols = [ "Worker", "ChromeWorker" ]; |
michael@0 | 41 | |
michael@0 | 42 | for each (var stage in stages) { |
michael@0 | 43 | for each (var symbol in symbols) { |
michael@0 | 44 | is(Services.prefs.getBoolPref("workertest.bootstrap." + stage + |
michael@0 | 45 | "." + symbol), |
michael@0 | 46 | true, |
michael@0 | 47 | "Symbol '" + symbol + "' present during '" + stage + "'"); |
michael@0 | 48 | } |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | SimpleTest.finish(); |
michael@0 | 52 | }); |
michael@0 | 53 | }, |
michael@0 | 54 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]) |
michael@0 | 55 | }; |
michael@0 | 56 | |
michael@0 | 57 | var workertestbootstrap = Cc["@mozilla.org/test/workertestbootstrap;1"]. |
michael@0 | 58 | createInstance(Ci.nsIObserver); |
michael@0 | 59 | |
michael@0 | 60 | workertestbootstrap.observe(observer, "postMessage", message); |
michael@0 | 61 | |
michael@0 | 62 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | ]]> |
michael@0 | 66 | </script> |
michael@0 | 67 | |
michael@0 | 68 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 69 | <p id="display"></p> |
michael@0 | 70 | <div id="content" style="display:none;"></div> |
michael@0 | 71 | <pre id="test"></pre> |
michael@0 | 72 | </body> |
michael@0 | 73 | <label id="test-result"/> |
michael@0 | 74 | </window> |