Bug 203981 - TestController may reuse a view that used window.open(), which prevents process-swapping and causes flakiness
Summary: TestController may reuse a view that used window.open(), which prevents proce...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 203965
  Show dependency treegraph
 
Reported: 2019-11-07 15:37 PST by Yury Semikhatsky
Modified: 2019-11-07 18:46 PST (History)
9 users (show)

See Also:


Attachments
WIP Patch (1.89 KB, patch)
2019-11-07 15:59 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (4.39 KB, patch)
2019-11-07 16:06 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (4.40 KB, patch)
2019-11-07 16:43 PST, Chris Dumez
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yury Semikhatsky 2019-11-07 15:37:46 PST
TestController may reuse Page for which previous test changed Page::openedByDOMWithOpener to true. This may disable PSON for cross-process navigation in subsequent tests and cause flakiness. See https://webkit.org/b/203965#c3 for one example how http/tests/dom/new-window-can-target-opener.html inadvertently disabled PSON for http/tests/inspector/target/target-events-for-provisional-page.html and made it fail.
Comment 1 Chris Dumez 2019-11-07 15:45:13 PST
trying to find this logic in TestController..
Comment 2 Chris Dumez 2019-11-07 15:53:02 PST
I think it is more likely we don't swap because: navigation.hasOpenedFrames(). Meaning that the previous test opened another window via window.open().
Comment 3 Chris Dumez 2019-11-07 15:59:49 PST
Created attachment 383086 [details]
WIP Patch
Comment 4 Chris Dumez 2019-11-07 16:06:30 PST
Created attachment 383087 [details]
Patch
Comment 5 Yury Semikhatsky 2019-11-07 16:19:56 PST
(In reply to Chris Dumez from comment #2)
> I think it is more likely we don't swap because:
> navigation.hasOpenedFrames(). Meaning that the previous test opened another
> window via window.open().

FWIW, while debugging the failure I saw

'"Browsing context been opened by DOM without 'noopener'"

coming from 
https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/UIProcess/WebProcessPool.cpp?rev=252014#L2139


Should be easy to reproduce by running:

Tools/Scripts/run-webkit-tests --no-show-results --no-retry-failures --child-processes=1 http/tests/dom/new-window-can-target-opener.html http/tests/inspector/target/target-events-for-provisional-page.html
Comment 6 Chris Dumez 2019-11-07 16:20:43 PST
(In reply to Yury Semikhatsky from comment #5)
> (In reply to Chris Dumez from comment #2)
> > I think it is more likely we don't swap because:
> > navigation.hasOpenedFrames(). Meaning that the previous test opened another
> > window via window.open().
> 
> FWIW, while debugging the failure I saw
> 
> '"Browsing context been opened by DOM without 'noopener'"
> 
> coming from 
> https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/UIProcess/
> WebProcessPool.cpp?rev=252014#L2139
> 
> 
> Should be easy to reproduce by running:
> 
> Tools/Scripts/run-webkit-tests --no-show-results --no-retry-failures
> --child-processes=1 http/tests/dom/new-window-can-target-opener.html
> http/tests/inspector/target/target-events-for-provisional-page.html

Yes, I have already confirmed that my fix addresses the flakiness with the command you provided.
Comment 7 Yury Semikhatsky 2019-11-07 16:26:29 PST
(In reply to Chris Dumez from comment #6)
> (In reply to Yury Semikhatsky from comment #5)
> > (In reply to Chris Dumez from comment #2)
> Yes, I have already confirmed that my fix addresses the flakiness with the
> command you provided.

Your change will certainly fix the test failure I was more concerned about the Process/Page being reused in prod. Since you mentioned hasOpenedFrames I wanted to double check if that's actually root cause because it didn't match what I saw in the output. In any case thanks for the quick fix!
Comment 8 Yury Semikhatsky 2019-11-07 16:27:06 PST
Comment on attachment 383087 [details]
Patch

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

lgtm

> Tools/WebKitTestRunner/TestController.cpp:774
> +        if (!m_createdOtherPage && m_mainWebView->viewSupportsOptions(options))

Neat!
Comment 9 Chris Dumez 2019-11-07 16:43:22 PST
Created attachment 383091 [details]
Patch
Comment 10 Chris Dumez 2019-11-07 18:45:11 PST
Committed r252228: <https://trac.webkit.org/changeset/252228>
Comment 11 Radar WebKit Bug Importer 2019-11-07 18:46:19 PST
<rdar://problem/57008023>