[Webkit-unassigned] [Bug 231375] New: DOMParser broken in iOS 15

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 7 10:56:11 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=231375

            Bug ID: 231375
           Summary: DOMParser broken in iOS 15
           Product: WebKit
           Version: Safari 15
          Hardware: iPhone / iPad
                OS: Other
            Status: NEW
          Severity: Critical
          Priority: P2
         Component: DOM
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: erik.witt at baqend.com

As describes in this ticket https://bugs.webkit.org/show_bug.cgi?id=231138 there is an issue where XHR with response type document does not parse and return a document despite a successful response from the server.

The bug however seems to span further. When I tried the workaround to fetch a text response via XHR and parse it with DOMParser, I discovered that this one is broken in some scenarios as well since it seemingly parses parts of the document but not all. 

This only happens on iOS 15 (iPhone 11 pro max for me)

Steps to reproduce:
1. Go to www.decathlon.de on your iOS 15 device
2. Use remote debugging to be able to use the console
2. Execute the following script
```
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open('GET', 'https://www.decathlon.de/browse/c0-alle-sportarten-a-z/c1-fahrrad-welt/c3-mountainbike/_/N-obq78x', true); 
xhr.responseType = 'text';

xhr.addEventListener('readystatechange', () => {
  if (xhr.readyState === 4) {
    console.log('Success')
    const parsedDocument = new DOMParser().parseFromString(xhr.response, 'text/html');

    console.log('Document')
    var scripts = Array.from(parsedDocument.querySelectorAll('script')).filter(s => !s.src)
    var lastScript = scripts[scripts.length - 1]
    console.log(lastScript.textContent);
  }
});

// Handle errors of XHR connection
xhr.addEventListener('error', (e) => {

    console.log('Error', e)
});
xhr.send();
```

The script print the content of the last inline script in the DOM. The script's content that is printed to the console should start with the line `var cube = cube || {};`. On iOS 15 Safari it starts with `window.fux = window.fux || {};` which is not the last inline script in the document!

If I print the whole string document to the console, I get the complete HTML text, also when I print the document object to the console, I get the full DOM. Only if I access the DOM by querying all the scripts for example it seems that there is half of the DOM missing.

On MAC OS Safari 15 it works without issues.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211007/4539afdf/attachment-0001.htm>


More information about the webkit-unassigned mailing list