mozilla-mobile / firefox-ios

Firefox for iOS
Mozilla Public License 2.0
12.15k stars 2.91k forks source link

Script error always thrown on page load #10817

Open kalkih opened 2 years ago

kalkih commented 2 years ago

Steps to reproduce

  1. Visit: https://kalkih.github.io/firefox-script-error-ios/
  2. An alert with the thrown ErrorEvent is shown.

The example to reproduce the issue consists of a window.addEventListener("error") which fires on the error and displays it in an alert Source code for the example: https://github.com/kalkih/firefox-script-error-ios/blob/main/index.html

Expected behavior

No error should be thrown on page load

Actual behavior

An error is thrown on page load which fires the window.addEventListener("error")

Device & build information

Notes

With "Enhanced Tracking Protection" switched to on, the error doesn't seem to be thrown when accessing a root page. Can be reproduced by serving the index.html page in the example locally on "/"

┆Issue is synchronized with this Jira Task

dnarcese commented 2 years ago

@kalkih can you clarify what the bug is? Is the error popup supposed to show at a different time?

TobbeLundberg commented 2 years ago

@kalkih I think the link to the source code is wrong. Should most likely be this: https://github.com/kalkih/firefox-script-error-ios/blob/main/index.html

@dnarcese The bug is that the alert is shown at all. It shouldn't be. It should only be shown on an error. And no error should be emitted by just loading the page.

wxiaoguang commented 2 years ago

I think it's also related to this one:

I wrote a reproducible demo (more complex)

TobbeLundberg commented 1 year ago

We're still running into this bug. I managed to get some more info out of the error message

IMG_0039

{
  "message": "Syntax Error: No identifiers allowed directly after numeric literal",
  "filename": "http://192.168.68.109:8080/",
  "lineno": 1,
  "colno": 0,
  "error": null
}

This is the source of the page

<html>
<body>
  <script>
    var errStringified = (err) =>
      JSON.stringify(
        Object.getOwnPropertyNames(Object.getPrototypeOf(err)).reduce((acc, cur) => {
          acc[cur] = err[cur];
          return acc;
        }, {})
      );

    window.addEventListener('error', e => {
      document.body.innerText = errStringified(e)
    })
  </script>
</body>
</html>
github-actions[bot] commented 4 days ago

This issue has been automatically marked as stale. Has the issue been fixed, or does it still require the community's attention? Please leave any comment to keep this issue opened. It will be closed automatically if no further update occurs in the next 30 days. Thank you for your contributions!

wxiaoguang commented 3 days ago

Well, nobody cared or tested the bug, just a "stale bot" tried to close the pending issues? Also see my example: Nonsense script error when inserting new elements into DOM #11191