Bug 1448484 - Intermittent devtools/client/storage/test/browser_storage_cookies_samesite.js | sameSite1 is Unset - Got undefined, expected Unset r?pbro draft
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Tue, 22 May 2018 12:21:11 +0100
changeset 798086 7d6525927410e9d70873b5588adfd7f3f87f850f
parent 798084 b75acf9652937ce79a9bf02de843c100db0e5ec7
push id110671
push userbmo:mratcliffe@mozilla.com
push dateTue, 22 May 2018 12:04:58 +0000
reviewerspbro
bugs1448484
milestone62.0a1
Bug 1448484 - Intermittent devtools/client/storage/test/browser_storage_cookies_samesite.js | sameSite1 is Unset - Got undefined, expected Unset r?pbro The problem is that we use this: this.front.on("stores-update", this.onEdit); But this.onEdit is async so we have race issues here. Luckily, only tests are fast enough to trigger race conditions in this type of instance. We also have similar issues caused by: - this.tree.on("select", this.onHostSelect); - this.table.on(TableWidget.EVENTS.SCROLL_END, this.handleScrollEnd); - this._refreshButton.addEventListener("command", this.onRefreshTable); Sadly this is a difficult issue to fix because adding async support to the event emitter would mean moving emit calls inside shared libraries into async method chains... the problem being that maybe we may not want the emitter to be asynchronous. The easy workaround for the moment is to add a small pause before reading the row values. This makes the most sense, especially considering that this tool needs converting to React / HTML at some point. MozReview-Commit-ID: 9fixDvkCAOX
devtools/client/storage/test/browser_storage_cookies_samesite.js
--- a/devtools/client/storage/test/browser_storage_cookies_samesite.js
+++ b/devtools/client/storage/test/browser_storage_cookies_samesite.js
@@ -20,18 +20,28 @@ add_task(async function() {
 
   await checkState([
     [
       ["cookies", "http://test1.example.org"],
       [ id1, id2, id3 ]
     ]
   ]);
 
-  let sameSite1 = getRowValues(id1).sameSite;
-  let sameSite2 = getRowValues(id2).sameSite;
-  let sameSite3 = getRowValues(id3).sameSite;
-
-  is(sameSite1, "Unset", `sameSite1 is "Unset"`);
-  is(sameSite2, "Lax", `sameSite2 is "Lax"`);
-  is(sameSite3, "Strict", `sameSite3 is "Strict"`);
-
+  await readValues(id1, id2, id3);
   await finishTests();
 });
+
+function readValues(id1, id2, id3) {
+  return new Promise(resolve => {
+    // eslint-disable-next-line
+    setTimeout(() => {
+      let sameSite1 = getRowValues(id1).sameSite;
+      let sameSite2 = getRowValues(id2).sameSite;
+      let sameSite3 = getRowValues(id3).sameSite;
+
+      is(sameSite1, "Unset", `sameSite1 is "Unset"`);
+      is(sameSite2, "Lax", `sameSite2 is "Lax"`);
+      is(sameSite3, "Strict", `sameSite3 is "Strict"`);
+
+      resolve();
+    }, 100);
+  });
+}