diff --git a/app-indexeddb-mirror/app-indexeddb-mirror-client.html b/app-indexeddb-mirror/app-indexeddb-mirror-client.html
index 5fec36b..5f6d8e7 100644
--- a/app-indexeddb-mirror/app-indexeddb-mirror-client.html
+++ b/app-indexeddb-mirror/app-indexeddb-mirror-client.html
@@ -57,6 +57,12 @@
* the session has been validated.
*/
validateSession: function(session) {
+ if (session === undefined) {
+ // Ignore session `undefined` conventionally, as it means the session
+ // (such as the user ID) has not been initialized yet.
+ return;
+ }
+
return this.post({
type: 'app-mirror-validate-session',
session: session
diff --git a/test/app-indexeddb-mirror/app-indexeddb-mirror.html b/test/app-indexeddb-mirror/app-indexeddb-mirror.html
index 3b9d8d0..58a0ecc 100644
--- a/test/app-indexeddb-mirror/app-indexeddb-mirror.html
+++ b/test/app-indexeddb-mirror/app-indexeddb-mirror.html
@@ -35,7 +35,15 @@
+ key="basic-mirror">
+
+
+
+
+
+
+
@@ -113,6 +121,32 @@
});
});
+ suite('when session is set lazily', function() {
+ var secondMirror;
+
+ setup(function() {
+ mirror.data = {
+ foo: 'bar'
+ };
+ secondMirror = fixture('NoSessionMirror');
+ return Promise.all([
+ mirror.transactionsComplete,
+ secondMirror.transactionsComplete
+ ]);
+ });
+
+ test('the data is preserved', function() {
+ if (!mirror.client.supportsMirroring) {
+ return;
+ }
+
+ secondMirror.session = 'test';
+ return secondMirror.transactionsComplete.then(function() {
+ return expectPersistedValue('basic-mirror', mirror.data);
+ });
+ });
+ });
+
suite('when offline', function() {
test('boots up with persisted value', function() {
if (!mirror.client.supportsMirroring) {