test WIP draft
authorIan Moody <moz-ian@perix.co.uk>
Tue, 05 Dec 2017 22:51:05 +0000
changeset 711816 ff87dd2dc7684fe8604fbfe0ab7ed35ada59aaa1
parent 711815 f6d5a4fdf6d5b4f33b4aaa2159a6d7a1093572a8
child 743886 b06061efce435bd728b26f8f706fd00b73793dcc
push id93157
push usermoz-ian@perix.co.uk
push dateThu, 14 Dec 2017 19:49:43 +0000
milestone59.0a1
test WIP MozReview-Commit-ID: CRhiVWYIw4P
.eslintignore
browser/components/sessionstore/test/unit/data/sessionstore_counts.js
browser/components/sessionstore/test/unit/test_session_counts.js
browser/components/sessionstore/test/unit/xpcshell.ini
--- a/.eslintignore
+++ b/.eslintignore
@@ -70,16 +70,17 @@ view/**
 browser/app/**
 browser/branding/**/firefox-branding.js
 # Gzipped test file.
 browser/base/content/test/general/gZipOfflineChild.html
 browser/base/content/test/urlbar/file_blank_but_not_blank.html
 # New tab is likely to be replaced soon.
 browser/base/content/newtab/**
 # Test files that are really json not js, and don't need to be linted.
+browser/components/sessionstore/test/unit/data/sessionstore_counts.js
 browser/components/sessionstore/test/unit/data/sessionstore_valid.js
 browser/components/sessionstore/test/unit/data/sessionstore_invalid.js
 # generated & special files in cld2
 browser/components/translation/cld2/**
 # Screenshots and Follow-on search are imported as a system add-on and have
 # their own lint rules currently.
 browser/extensions/followonsearch/**
 browser/extensions/screenshots/**
new file mode 100644
--- /dev/null
+++ b/browser/components/sessionstore/test/unit/data/sessionstore_counts.js
@@ -0,0 +1,11 @@
+{
+  "windows": [
+    {"tabs": [
+      {"url": "http://example.com/1"},
+      {"url": "http://example.com/2"}
+    ]},
+    {"tabs": [
+      {"url": "http://example.com/3"}
+    ]}
+  ]
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/browser/components/sessionstore/test/unit/test_session_counts.js
@@ -0,0 +1,33 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+function run_test() {
+  let profd = do_get_profile();
+  const {SessionFile} = Cu.import("resource:///modules/sessionstore/SessionFile.jsm", {});
+
+  let sourceSession = do_get_file("data/sessionstore_counts.js");
+  sourceSession.copyTo(profd, "sessionstore.js");
+
+  let sourceCheckpoints = do_get_file("data/sessionCheckpoints_all.json");
+  sourceCheckpoints.copyTo(profd, "sessionCheckpoints.json");
+
+  // Compress sessionstore.js to sessionstore.jsonlz4
+  // and remove sessionstore.js
+  let oldExtSessionFile = SessionFile.Paths.clean.replace("jsonlz4", "js");
+  writeCompressedFile(oldExtSessionFile, SessionFile.Paths.clean).then(() => {
+    afterSessionStartupInitialization(async function cb() {
+      const {SessionStore} = Cu.import("resource:///modules/sessionstore/SessionStore.jsm", {});
+
+      let ssp = SessionStore.promiseInitialized;
+      SessionStore.init()
+      await ssp;
+
+      deepEqual(SessionStore.restorableObjectsCount, {windows: 2, tabs: 3});
+      do_test_finished();
+    });
+  });
+
+  do_test_pending();
+}
--- a/browser/components/sessionstore/test/unit/xpcshell.ini
+++ b/browser/components/sessionstore/test/unit/xpcshell.ini
@@ -1,17 +1,19 @@
 [DEFAULT]
 head = head.js
 firefox-appdir = browser
 skip-if = toolkit == 'android'
 support-files =
   data/sessionCheckpoints_all.json
+  data/sessionstore_counts.js
   data/sessionstore_invalid.js
   data/sessionstore_valid.js
 
 [test_backup_once.js]
 [test_histogram_corrupt_files.js]
 [test_migration_lz4compression.js]
 [test_scalar_worker_restarts.js]
+[test_session_counts.js]
 [test_shutdown_cleanup.js]
 [test_startup_nosession_async.js]
 [test_startup_session_async.js]
 [test_startup_invalid_session.js]