Closed Bug 1610327 Opened 5 years ago Closed 11 months ago

Gutenberg test hang at beforeunload prompt

Categories

(Remote Protocol :: CDP, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: impossibus, Unassigned)

References

Details

Most gutenberg tests hang due to a "Stay on Page"/"Leave Page" dialog. ("This page is asking you to confirm that you want to leave...").

Perhaps bug 1545724 didn't fix the beforeunload prompt handling.

Whiteboard: [puppeteer-beta-reserve] → [puppeteer-beta-reserve][puppeteer-high-priority]
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Whiteboard: [puppeteer-beta-reserve][puppeteer-high-priority] → [puppeteer-beta-reserve]
Whiteboard: [puppeteer-beta-reserve]

More detail: In contrast with Chrome, Firefox shows a beforeunload dialog, emits Page.javascriptDialogOpening and hangs. I thought it was an issue with Browser.close() but that's not the case. Comparing Chrome and Firefox debug logs doesn't reveal any differences except for the extra javascriptDialogOpening event.

Setting 'dom.disable_beforeunload': true stops this behaviour, so that's at least a temporary workaround.

Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Summary: Puppeteer script hangs at beforeunload prompt → Gutenberg test hang at beforeunload prompt

So you are saying that Chrome never shows beforeunload prompts? At least when I check Page.close it seems to be disabled by default (note that the docs don't even mention the runBeforeUnload option). So when does it hang exactly?

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #3)

So you are saying that Chrome never shows beforeunload prompts?

Running in slowmo, I see no prompts in Chrome.

At least when I check Page.close it seems to be disabled by default (note that the docs don't even mention the runBeforeUnload option). So when does it hang exactly?

I wonder actually if something else is invoking Target.closeTarget. I can't find any calls to Page.close in gutenberg.

At the end of the test, Firefox shows a prompt and emits javascriptDialogOpening, and that's where it hangs.

End of Firefox log (hang):

puppeteer:protocol SEND ► {"method":"Target.closeTarget","params":{"targetId":11},"id":98} +4ms
  puppeteer:protocol ◀ RECV {"sessionId":1,"method":"Network.requestWillBeSent","params":{"requestId":"379352986419671","documentURL":"http://localhost:8889/wp-admin/post-new.php","request":{"url":"http://localhost:8889/wp-admin/admin-ajax.php","method":"POST","headers":[],"hasPostData":false,"isLinkPreload":false},"type":"Beacon","frameId":"11"}} +14ms
  puppeteer:protocol ◀ RECV {"sessionId":1,"method":"Page.javascriptDialogOpening","params":{"message":"This page is asking you to confirm that you want to leave - data you have entered may not be saved.","type":"beforeunload"}} +30ms
  puppeteer:protocol ◀ RECV {"sessionId":1,"method":"Log.entryAdded","params":{"entry":{"source":"javascript","level":"verbose","text":"[Exception... \"Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIContentSniffer.getMIMETypeFromContent]\"  nsresult: \"0x80040111 (NS_ERROR_NOT_AVAILABLE)\"  location: \"JS frame :: resource:///modules/FaviconLoader.jsm :: onStopRequest :: line 295\"  data: no]","timestamp":1579627681027,"url":"","lineNumber":0,"stackTrace":{}}}} +598ms

End of Chrome log:

puppeteer:protocol SEND ► {"method":"Target.closeTarget","params":{"targetId":"A4E73F2828AA084A18227A19348F159A"},"id":98} +15ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"A4E73F2828AA084A18227A19348F159A","type":"page","title":"Add New Post \u2039 WordPress Develop \u2014 WordPress","url":"http://localhost:8889/wp-admin/post-new.php","attached":false,"browserContextId":"5AC56BABA1033A9443AC9DA9E061D663"}}} +23ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetDestroyed","params":{"targetId":"A4E73F2828AA084A18227A19348F159A"}} +0ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"A4E73F2828AA084A18227A19348F159A","type":"page","title":"Add New Post \u2039 WordPress Develop \u2014 WordPress","url":"http://localhost:8889/wp-admin/post-new.php","attached":false,"browserContextId":"5AC56BABA1033A9443AC9DA9E061D663"}}} +1ms
  puppeteer:protocol ◀ RECV {"method":"Target.detachedFromTarget","params":{"sessionId":"A2712B94791249C8816115CA579D9FA4","targetId":"A4E73F2828AA084A18227A19348F159A"}} +28ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetDestroyed","params":{"targetId":"A4E73F2828AA084A18227A19348F159A"}} +2ms
  puppeteer:protocol ◀ RECV {"id":98,"result":{"success":true}} +4ms

Yes, that's what I expected to see. So as you already proposed, lets get this pref set to false for now, and take care of the Page.close case later.

Component: CDP: Page → CDP
Severity: normal → S3

Gutenberg tests are moving away from Puppeteer.

Status: REOPENED → RESOLVED
Closed: 5 years ago11 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.