diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/test/unit_ipc/child_app_offline_notifications.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit_ipc/child_app_offline_notifications.js')
-rw-r--r-- | netwerk/test/unit_ipc/child_app_offline_notifications.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/netwerk/test/unit_ipc/child_app_offline_notifications.js b/netwerk/test/unit_ipc/child_app_offline_notifications.js new file mode 100644 index 000000000..870c22b39 --- /dev/null +++ b/netwerk/test/unit_ipc/child_app_offline_notifications.js @@ -0,0 +1,43 @@ +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + +function is_app_offline(appId) { + let ioservice = Cc['@mozilla.org/network/io-service;1']. + getService(Ci.nsIIOService); + return ioservice.isAppOffline(appId); +} + +var events_observed_no = 0; + +// Holds the last observed app-offline event +var info = null; +function observer(aSubject, aTopic, aData) { + events_observed_no++; + info = aSubject.QueryInterface(Ci.nsIAppOfflineInfo); + dump("ChildObserver - subject: {" + aSubject.appId + ", " + aSubject.mode + "} "); +} + +// Add observer for the app-offline notification +function run_test() { + Services.obs.addObserver(observer, "network:app-offline-status-changed", false); +} + +// Chech that the app has the proper offline status +function check_status(appId, status) +{ + do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE); +} + +// Check that the app has the proper offline status +// and that the correct notification has been received +function check_notification_and_status(appId, status) { + do_check_eq(info.appId, appId); + do_check_eq(info.mode, status); + do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE); +} + +// Remove the observer from the child process +function finished() { + Services.obs.removeObserver(observer, "network:app-offline-status-changed"); + do_check_eq(events_observed_no, 2); +} |