diff options
Diffstat (limited to 'services/sync/tests/unit/test_tab_tracker.js')
-rw-r--r-- | services/sync/tests/unit/test_tab_tracker.js | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/services/sync/tests/unit/test_tab_tracker.js b/services/sync/tests/unit/test_tab_tracker.js index f98920a44..e7dd48829 100644 --- a/services/sync/tests/unit/test_tab_tracker.js +++ b/services/sync/tests/unit/test_tab_tracker.js @@ -5,7 +5,7 @@ Cu.import("resource://services-sync/engines/tabs.js"); Cu.import("resource://services-sync/service.js"); Cu.import("resource://services-sync/util.js"); -var clientsEngine = Service.clientsEngine; +let clientsEngine = Service.clientsEngine; function fakeSvcWinMediator() { // actions on windows are captured in logs @@ -15,11 +15,9 @@ function fakeSvcWinMediator() { getEnumerator: function() { return { cnt: 2, - hasMoreElements: function() { - return this.cnt-- > 0; - }, + hasMoreElements: function() this.cnt-- > 0, getNext: function() { - let elt = {addTopics: [], remTopics: [], numAPL: 0, numRPL: 0}; + let elt = {addTopics: [], remTopics: []}; logs.push(elt); return { addEventListener: function(topic) { @@ -27,15 +25,7 @@ function fakeSvcWinMediator() { }, removeEventListener: function(topic) { elt.remTopics.push(topic); - }, - gBrowser: { - addProgressListener() { - elt.numAPL++; - }, - removeProgressListener() { - elt.numRPL++; - }, - }, + } }; } }; @@ -61,7 +51,7 @@ function run_test() { logs = fakeSvcWinMediator(); Svc.Obs.notify("weave:engine:start-tracking"); do_check_eq(logs.length, 2); - for (let log of logs) { + for each (let log in logs) { do_check_eq(log.addTopics.length, 5); do_check_true(log.addTopics.indexOf("pageshow") >= 0); do_check_true(log.addTopics.indexOf("TabOpen") >= 0); @@ -69,15 +59,13 @@ function run_test() { do_check_true(log.addTopics.indexOf("TabSelect") >= 0); do_check_true(log.addTopics.indexOf("unload") >= 0); do_check_eq(log.remTopics.length, 0); - do_check_eq(log.numAPL, 1, "Added 1 progress listener"); - do_check_eq(log.numRPL, 0, "Didn't remove a progress listener"); } _("Test listeners are unregistered on windows"); logs = fakeSvcWinMediator(); Svc.Obs.notify("weave:engine:stop-tracking"); do_check_eq(logs.length, 2); - for (let log of logs) { + for each (let log in logs) { do_check_eq(log.addTopics.length, 0); do_check_eq(log.remTopics.length, 5); do_check_true(log.remTopics.indexOf("pageshow") >= 0); @@ -85,12 +73,10 @@ function run_test() { do_check_true(log.remTopics.indexOf("TabClose") >= 0); do_check_true(log.remTopics.indexOf("TabSelect") >= 0); do_check_true(log.remTopics.indexOf("unload") >= 0); - do_check_eq(log.numAPL, 0, "Didn't add a progress listener"); - do_check_eq(log.numRPL, 1, "Removed 1 progress listener"); } _("Test tab listener"); - for (let evttype of ["TabOpen", "TabClose", "TabSelect"]) { + for each (let evttype in ["TabOpen", "TabClose", "TabSelect"]) { // Pretend we just synced. tracker.clearChangedIDs(); do_check_false(tracker.modified); @@ -109,19 +95,4 @@ function run_test() { tracker.onTab({type: "pageshow", originalTarget: "pageshow"}); do_check_true(Utils.deepEquals(Object.keys(engine.getChangedIDs()), [clientsEngine.localID])); - - // Pretend we just synced and saw some progress listeners. - tracker.clearChangedIDs(); - do_check_false(tracker.modified); - tracker.onLocationChange({ isTopLevel: false }, undefined, undefined, 0); - do_check_false(tracker.modified, "non-toplevel request didn't flag as modified"); - - tracker.onLocationChange({ isTopLevel: true }, undefined, undefined, - Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT); - do_check_false(tracker.modified, "location change within the same document request didn't flag as modified"); - - tracker.onLocationChange({ isTopLevel: true }, undefined, undefined, 0); - do_check_true(tracker.modified, "location change for a new top-level document flagged as modified"); - do_check_true(Utils.deepEquals(Object.keys(engine.getChangedIDs()), - [clientsEngine.localID])); } |