Bug 228569

Summary: storage/indexeddb/detached-iframe.html is flaky on some bots
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Tools / TestsAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, alecflett, beidson, ews-watchlist, ggaren, jsbell, Lawrence.j, sihui_liu, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Chris Dumez 2021-07-28 15:24:14 PDT
storage/indexeddb/detached-iframe.html is flaky on some bots:

TEXT DIFF:
 ALERT: original value
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 PASS successfullyParsed is true
 
 TEST COMPLETE
Comment 1 Chris Dumez 2021-07-28 15:24:24 PDT
<rdar://80396559>
Comment 2 Chris Dumez 2021-07-28 15:26:22 PDT
Created attachment 434472 [details]
Patch
Comment 3 Sihui Liu 2021-07-28 16:22:30 PDT
Comment on attachment 434472 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434472&action=review

> LayoutTests/storage/indexeddb/detached-iframe.html:7
> +jsTestIsAsync = true;

Isn't it set in shared.js?
Comment 4 Chris Dumez 2021-07-28 16:24:53 PDT
Comment on attachment 434472 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434472&action=review

>> LayoutTests/storage/indexeddb/detached-iframe.html:7
>> +jsTestIsAsync = true;
> 
> Isn't it set in shared.js?

Hmm, it does. Yet, my change is causing the output to show up so there is a behavior change somehow..
Comment 5 Chris Dumez 2021-07-28 16:27:06 PDT
Comment on attachment 434472 [details]
Patch

Will investigate further.
Comment 6 Sihui Liu 2021-07-28 16:28:23 PDT
(In reply to Chris Dumez from comment #4)
> Comment on attachment 434472 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=434472&action=review
> 
> >> LayoutTests/storage/indexeddb/detached-iframe.html:7
> >> +jsTestIsAsync = true;
> > 
> > Isn't it set in shared.js?
> 
> Hmm, it does. Yet, my change is causing the output to show up so there is a
> behavior change somehow..

Probably output from description()
Comment 7 Chris Dumez 2021-07-28 16:32:37 PDT
Comment on attachment 434472 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434472&action=review

> LayoutTests/storage/indexeddb/detached-iframe-expected.txt:2
> +IndexedDB edge case with a detached iframe.

description() would add this logging ...

> LayoutTests/storage/indexeddb/detached-iframe-expected.txt:4
> +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

... and this one.

> LayoutTests/storage/indexeddb/detached-iframe-expected.txt:7
> +indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;

description() does not explain this logging?
Comment 8 Sihui Liu 2021-07-28 22:01:11 PDT
(In reply to Chris Dumez from comment #7)
> Comment on attachment 434472 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=434472&action=review
> 
> > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:2
> > +IndexedDB edge case with a detached iframe.
> 
> description() would add this logging ...
> 
> > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:4
> > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
> 
> ... and this one.
> 
> > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:7
> > +indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
> 
> description() does not explain this logging?

Right, I thought these lines should always be printed. Something wrong with the DOM nodes...

testIframe.parentNode.remove(testIframe);
should probably be:
testIframe.parentNode.removeChild(testIframe);
Comment 9 Chris Dumez 2021-07-29 08:32:37 PDT
(In reply to Sihui Liu from comment #8)
> (In reply to Chris Dumez from comment #7)
> > Comment on attachment 434472 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=434472&action=review
> > 
> > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:2
> > > +IndexedDB edge case with a detached iframe.
> > 
> > description() would add this logging ...
> > 
> > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:4
> > > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
> > 
> > ... and this one.
> > 
> > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:7
> > > +indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
> > 
> > description() does not explain this logging?
> 
> Right, I thought these lines should always be printed. Something wrong with
> the DOM nodes...
> 
> testIframe.parentNode.remove(testIframe);
> should probably be:
> testIframe.parentNode.removeChild(testIframe);

It's equivalent, so is `testIframe.remove()`. It has no impact on the output of the test. Just adding the description() makes the output show (seemingly consistently) but I don't have an explanation why at the moment...
Comment 10 Chris Dumez 2021-07-29 08:42:03 PDT
Created attachment 434523 [details]
Patch
Comment 11 Sihui Liu 2021-07-29 08:49:00 PDT
(In reply to Chris Dumez from comment #9)
> (In reply to Sihui Liu from comment #8)
> > (In reply to Chris Dumez from comment #7)
> > > Comment on attachment 434472 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=434472&action=review
> > > 
> > > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:2
> > > > +IndexedDB edge case with a detached iframe.
> > > 
> > > description() would add this logging ...
> > > 
> > > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:4
> > > > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
> > > 
> > > ... and this one.
> > > 
> > > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:7
> > > > +indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
> > > 
> > > description() does not explain this logging?
> > 
> > Right, I thought these lines should always be printed. Something wrong with
> > the DOM nodes...
> > 
> > testIframe.parentNode.remove(testIframe);
> > should probably be:
> > testIframe.parentNode.removeChild(testIframe);
> 
> It's equivalent, so is `testIframe.remove()`. It has no impact on the output
> of the test. Just adding the description() makes the output show (seemingly
> consistently) but I don't have an explanation why at the moment...

I checked with MutationObserver, testIframe.parentNode.remove(testIframe) removes document.body, testIframe.parentNode.removeChild(testIframe) removes iframe. Removing document.body makes the console element added in different places (function getOrCreate(id, tagName)@js-tests.js)...
Comment 12 Chris Dumez 2021-07-29 08:53:26 PDT
(In reply to Sihui Liu from comment #11)
> (In reply to Chris Dumez from comment #9)
> > (In reply to Sihui Liu from comment #8)
> > > (In reply to Chris Dumez from comment #7)
> > > > Comment on attachment 434472 [details]
> > > > Patch
> > > > 
> > > > View in context:
> > > > https://bugs.webkit.org/attachment.cgi?id=434472&action=review
> > > > 
> > > > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:2
> > > > > +IndexedDB edge case with a detached iframe.
> > > > 
> > > > description() would add this logging ...
> > > > 
> > > > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:4
> > > > > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
> > > > 
> > > > ... and this one.
> > > > 
> > > > > LayoutTests/storage/indexeddb/detached-iframe-expected.txt:7
> > > > > +indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
> > > > 
> > > > description() does not explain this logging?
> > > 
> > > Right, I thought these lines should always be printed. Something wrong with
> > > the DOM nodes...
> > > 
> > > testIframe.parentNode.remove(testIframe);
> > > should probably be:
> > > testIframe.parentNode.removeChild(testIframe);
> > 
> > It's equivalent, so is `testIframe.remove()`. It has no impact on the output
> > of the test. Just adding the description() makes the output show (seemingly
> > consistently) but I don't have an explanation why at the moment...
> 
> I checked with MutationObserver, testIframe.parentNode.remove(testIframe)
> removes document.body, testIframe.parentNode.removeChild(testIframe) removes
> iframe. Removing document.body makes the console element added in different
> places (function getOrCreate(id, tagName)@js-tests.js)...

Oh, you are right that testIframe.parentNode.remove(testIframe) seems very wrong. It removes the parent node instead of the frame, LOL :)
I got confused because ParentNode.idl has append/prepend (but not remove).

I'll test again but I believe fixing that didn't make the output appear though. For me, it was switching to js-test-pre.js/js-test-post.js (or calling description()) that seemed to do the trick.
Comment 13 Chris Dumez 2021-07-29 09:10:36 PDT
Comment on attachment 434523 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434523&action=review

> LayoutTests/storage/indexeddb/detached-iframe.html:8
> +    document.getElementById('testIframe').remove();

Actually, this fix alone is sufficient to make the output show. I got confused because the test is marked as flaky internally.

I'll revert the js-test-pre.js / js-test-post.js change.
Comment 14 Chris Dumez 2021-07-29 09:14:23 PDT
Created attachment 434527 [details]
Patch
Comment 15 EWS 2021-07-29 09:55:56 PDT
Committed r280426 (240066@main): <https://commits.webkit.org/240066@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 434527 [details].
Comment 16 Chris Dumez 2021-07-29 10:02:34 PDT
*** Bug 207844 has been marked as a duplicate of this bug. ***
Comment 17 Chris Dumez 2021-07-29 10:05:01 PDT
Unskipped test in <https://commits.webkit.org/r280427>.