Closed Bug 1862380 Opened 11 months ago Closed 4 months ago

Add support for "promptUnload" argument for "browsingContext.close" command

Categories

(Remote Protocol :: WebDriver BiDi, enhancement, P2)

enhancement
Points:
3

Tracking

(firefox129 fixed)

RESOLVED FIXED
129 Branch
Tracking Status
firefox129 --- fixed

People

(Reporter: whimboo, Assigned: whimboo)

References

(Blocks 2 open bugs, )

Details

(Whiteboard: [webdriver:m11][wptsync upstream][webdriver:relnote])

Attachments

(2 files)

The promptUnload argument has recently been added to the browsingContext.close command via https://github.com/w3c/webdriver-bidi/pull/518. This allows to control if a beforeunload prompt should be shown or not.

I've asked for some tests and will add a downstream sync bug as dependency once a PR on the wpt repository has been created.

Type: task → enhancement

Right now we do not support beforeunload prompts at all in Marionette. So these need to be enabled first, before we can add support for it in WebDriver BiDi via bug 1824220.

Priority: -- → P3
Whiteboard: [webdriver:backlog]
Points: --- → 3
Whiteboard: [webdriver:backlog] → [webdriver:m10]
Priority: P3 → P2

Wdspec tests will be added upstream via bug 1874748.

Depends on: 1874748
Whiteboard: [webdriver:m10] → [webdriver:m11]

To properly write tests for the prompt opened and prompt closed feature on bug 1824220 I need support for this argument. The upstream wpt tests aren't done yet, so I've asked for them to get finished. If it takes longer we could land the patch anyway given that we need this feature when testing pages where we dismiss the beforeunload prompt.

Assignee: nobody → hskupin
Blocks: 1824220
Status: NEW → ASSIGNED
No longer depends on: 1824220

With the patch applied network event related wdspec tests are failing.

After investigation it can be seen that the service worker test, which runs before, seems to cause an invalid response to be sent. But that only when I call removeTab with the skipPermitUnload field set to true. Here is what we get when it fails:

    {
        'context': '5be553b8-3e45-4952-acc4-fdad6799f386',
        'isBlocked': False,
        'navigation': None,
        'redirectCount': 0,
        'request': {
          'request': '4',
          'url': 'https://web-platform.test:8443/webdriver/tests/support/http_handlers/cached.py?status=200&nocache=0.2595580275756214',
          'method': 'GET',
          'bodySize': 0,
          'headersSize': 0,
          'headers': [
            {
              'name': 'Host',
              'value': {
                'type': 'string',
                'value': 'web-platform.test:8443'
              }
            },
            {
              'name': 'User-Agent',
              'value': {
                'type': 'string',
                'value': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0'
              }
            },
            {
              'name': 'Accept',
              'value': {
                'type': 'string',
                'value': '*/*'
              }
            },
            {
              'name': 'Accept-Language',
              'value': {
                'type': 'string',
                'value': 'en-US,en;q=0.5'
              }
            },
            {
              'name': 'Accept-Encoding',
              'value': {
                'type': 'string',
                'value': 'gzip, deflate, br, zstd'
              }
            },
            {
              'name': 'Referer',
              'value': {
                'type': 'string',
                'value': 'https://web-platform.test:8443/webdriver/tests/bidi/network/support/empty.html'
              }
            },
            {
              'name': 'Sec-Fetch-Dest',
              'value': {
                'type': 'string',
                'value': 'empty'
              }
            },
            {
              'name': 'Sec-Fetch-Mode',
              'value': {
                'type': 'string',
                'value': 'cors'
              }
            },
            {
              'name': 'Sec-Fetch-Site',
              'value': {
                'type': 'string',
                'value': 'same-origin'
              }
            },
            {
              'name': 'Connection',
              'value': {
                'type': 'string',
                'value': 'keep-alive'
              }
            }
          ],
          'cookies': [
            
          ],
          'timings': {
            'timeOrigin': 0,
            'requestTime': 1718286785303727,
            'redirectStart': 0,
            'redirectEnd': 0,
            'fetchStart': 1718286785305017,
            'dnsStart': 0,
            'dnsEnd': 0,
            'connectStart': 0,
            'connectEnd': 0,
            'tlsStart': 0,
            'tlsEnd': 0,
            'requestStart': 0,
            'responseStart': 0,
            'responseEnd': 0
          }
        },
        'timestamp': 1718286785315,
        'response': {
          'url': 'https://web-platform.test:8443/webdriver/tests/support/http_handlers/cached.py?status=200&nocache=0.2595580275756214',
          'protocol': 'http/1.1',
          'status': 200,
          'statusText': 'OK from serviceworker',
          'fromCache': True,
          'headers': [
            {
              'name': 'Content-Type',
              'value': {
                'type': 'string',
                'value': 'text/plain;charset=UTF-8'
              }
            }
          ],
          'mimeType': ';charset=UTF-8',
          'bytesReceived': 0,
          'headersSize': 0,
          'bodySize': 0,
          'content': {
            'size': 23
          }
        }
      }

As it can be seen we did not request the service worker HTML file, but actually got the OK from serviceworker as status text for a request of the https://web-platform.test:8443/webdriver/tests/support/http_handlers/cached.py page.

Julian, any idea why this could happen? Not sure how permitting beforeunload or not should have an effect here when even not a beforeunload prompt is shown. Is that some hick-up with the Network cache?

Flags: needinfo?(jdescottes)

As discussed on Matrix, the issue is coming from the service worker test page, which currently uses beforeunload to unregister the serviceworker https://searchfox.org/mozilla-central/rev/4c8627a76e2e0a9b49c2b673424da478e08715ad/testing/web-platform/tests/webdriver/tests/bidi/network/support/serviceworker.html#26-28

We can switch to pagehide or explicitly unregister the SW.

Flags: needinfo?(jdescottes)
Pushed by hskupin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/858f1c8e017c [wdspec] Unregister service worker on pagehide and not beforeunload. r=webdriver-reviewers,Sasha https://hg.mozilla.org/integration/autoland/rev/29d2b1bc7b4f [webdriver-bidi] Support the "promptUnload" argument for "browsingContext.close". r=webdriver-reviewers,Sasha
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/46749 for changes under testing/web-platform/tests
Whiteboard: [webdriver:m11] → [webdriver:m11], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch
Upstream PR merged by moz-wptsync-bot
Whiteboard: [webdriver:m11], [wptsync upstream] → [webdriver:m11][wptsync upstream][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: