diff options
author | Trevor Elliott <trevor@galois.com> | 2013-06-07 16:42:11 -0700 |
---|---|---|
committer | Trevor Elliott <trevor@galois.com> | 2013-06-07 16:48:17 -0700 |
commit | 8b5d3c6b75744cf5938f253d20f367999e92b1a7 (patch) | |
tree | b516a82c5b198fd080d265e56b3edf19d1180f10 /tools/addon-sdk-1.12/test/test-observer-service.js | |
parent | f37588f9a4c7c6b418c64f03d82d48ecd14da217 (diff) |
Remove the addon-sdk from the repo, and download it on demand
Diffstat (limited to 'tools/addon-sdk-1.12/test/test-observer-service.js')
-rw-r--r-- | tools/addon-sdk-1.12/test/test-observer-service.js | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/tools/addon-sdk-1.12/test/test-observer-service.js b/tools/addon-sdk-1.12/test/test-observer-service.js deleted file mode 100644 index bd4c903..0000000 --- a/tools/addon-sdk-1.12/test/test-observer-service.js +++ /dev/null @@ -1,80 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const observers = require("sdk/deprecated/observer-service"); -const { Cc, Ci } = require("chrome"); -const { Loader } = require("sdk/test/loader"); -const { PlainTextConsole } = require("sdk/console/plain-text"); - -exports.testUnloadAndErrorLogging = function(test) { - var prints = []; - var loader = Loader(module, { - console: new PlainTextConsole(function(_) { - prints.push(_); - }) - }); - var sbobsvc = loader.require("sdk/deprecated/observer-service"); - - var timesCalled = 0; - var cb = function(subject, data) { - timesCalled++; - }; - var badCb = function(subject, data) { - throw new Error("foo"); - }; - sbobsvc.add("blarg", cb); - observers.notify("blarg", "yo yo"); - test.assertEqual(timesCalled, 1); - sbobsvc.add("narg", badCb); - observers.notify("narg", "yo yo"); - var lines = prints[0].split("\n"); - test.assertEqual(lines[0], "error: " + require("sdk/self").name + ": An exception occurred."); - test.assertEqual(lines[1], "Traceback (most recent call last):"); - test.assertEqual(lines.slice(-2)[0], "Error: foo"); - - loader.unload(); - observers.notify("blarg", "yo yo"); - test.assertEqual(timesCalled, 1); -}; - -exports.testObserverService = function(test) { - var ios = Cc['@mozilla.org/network/io-service;1'] - .getService(Ci.nsIIOService); - var service = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - var uri = ios.newURI("http://www.foo.com", null, null); - var timesCalled = 0; - var lastSubject = null; - var lastData = null; - - var cb = function(subject, data) { - timesCalled++; - lastSubject = subject; - lastData = data; - }; - - observers.add("blarg", cb); - service.notifyObservers(uri, "blarg", "some data"); - test.assertEqual(timesCalled, 1, - "observer-service.add() should call callback"); - test.assertEqual(lastSubject, uri, - "observer-service.add() should pass subject"); - test.assertEqual(lastData, "some data", - "observer-service.add() should pass data"); - - function customSubject() {} - function customData() {} - observers.notify("blarg", customSubject, customData); - test.assertEqual(timesCalled, 2, - "observer-service.notify() should work"); - test.assertEqual(lastSubject, customSubject, - "observer-service.notify() should pass+wrap subject"); - test.assertEqual(lastData, customData, - "observer-service.notify() should pass data"); - - observers.remove("blarg", cb); - service.notifyObservers(null, "blarg", "some data"); - test.assertEqual(timesCalled, 2, - "observer-service.remove() should work"); -}; |