summaryrefslogtreecommitdiffstats
path: root/dom/settings/tests/test_settings_service_callback.js
blob: a780bb9c329d01eb0978b82cb5fc4f2f24df1791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";

var Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

SimpleTest.waitForExplicitFinish();

XPCOMUtils.defineLazyServiceGetter(this, "SettingsService",
                                   "@mozilla.org/settingsService;1",
                                   "nsISettingsService");

var tests = [
  function () {
    let callback = {
      handle: function() {
        ok(true, "handle called!");
        next();
      },

      handleAbort: function(name) {
        ok(false, "error: " + name);
        next();
      }
    }
    let lock = SettingsService.createLock(callback);
    lock.set("xasdf", true, null, null);
  }
];

function next() {
  let step = tests.shift();
  if (step) {
    try {
      step();
    } catch(e) {
      ok(false, "Test threw: " + e);
    }
  } else {
    SimpleTest.finish();
  }
}

next();