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
--- 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);
+ });
+}