1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
6 const Ci = SpecialPowers.Ci;
7 const Cu = SpecialPowers.Cu;
9 SpecialPowers.setBoolPref("toolkit.identity.debug", true);
10 SpecialPowers.setBoolPref("dom.identity.enabled", true);
12 const Services = Cu.import("resource://gre/modules/Services.jsm").Services;
13 const DOMIdentity = Cu.import("resource://gre/modules/DOMIdentity.jsm")
16 let util = SpecialPowers.getDOMWindowUtils(window);
17 let outerWinId = util.outerWindowID;
19 const identity = navigator.id || navigator.mozId;
23 // mimicking callback funtionality for ease of testing
24 // this observer auto-removes itself after the observe function
25 // is called, so this is meant to observe only ONE event.
26 function makeObserver(aObserveTopic, aObserveFunc) {
27 function observe(aSubject, aTopic, aData) {
28 if (aTopic == aObserveTopic) {
29 aObserveFunc(aSubject, aTopic, aData);
30 Services.obs.removeObserver(this, aObserveTopic);
34 Services.obs.addObserver(observe, aObserveTopic, false);
37 function expectException(aFunc, msg, aErrorType="Error") {
38 info("Expecting an exception: " + msg);
44 let exProto = Object.getPrototypeOf(ex);
45 // Don't count NS_* exceptions since they shouldn't be exposed to content
46 if (exProto.toString() == aErrorType
47 && ex.toString().indexOf("NS_ERROR_FAILURE") == -1) {
54 isnot(caughtEx, null, "Check for thrown exception.");
59 todo(false, "DOM API is not available. Skipping tests.");
63 if (index >= steps.length) {
64 ok(false, "Shouldn't get here!");
68 let fn = steps[index];
69 info("Begin test " + index + " '" + steps[index].name + "'!");
72 ok(false, "Caught exception", ex);
77 function finish_tests() {
79 SpecialPowers.clearUserPref("toolkit.identity.debug");
80 SpecialPowers.clearUserPref("dom.identity.enabled");