mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix breakage on Firefox iOS
Summary: Grist recently stopped working on Firefox on iOS. The cause turns out an uncaught error, which is reported as an unhelpful "Script Error", but the act of reporting it causes additional errors, leading to an infinite loop and an unusable browser tab. Firefox-iOS is to blame, but a workaround is preventing a flood of "Script Error" messages. Specifically, we report only the first of these, and only to the server, suppressing the user-visible toast. Test Plan: Tested manually on Firefox on iOS. Added a test case, and improve other tests of uncaught errors. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3902
This commit is contained in:
@@ -3068,6 +3068,19 @@ export async function assertIsRickRowing(expected: boolean) {
|
||||
assert.equal(await driver.find('iframe#youtube-player-dQw4w9WgXcQ').isPresent(), expected);
|
||||
}
|
||||
|
||||
|
||||
export function produceUncaughtError(message: string) {
|
||||
// Simply throwing an error from driver.executeScript() may produce a sanitized "Script error",
|
||||
// depending on browser/webdriver version. This is a trick to ensure the uncaught error is
|
||||
// considered same-origin by the main window.
|
||||
return driver.executeScript((msg: string) => {
|
||||
const script = document.createElement("script");
|
||||
script.type = "text/javascript";
|
||||
script.innerText = 'setTimeout(() => { throw new Error(' + JSON.stringify(msg) + '); }, 0)';
|
||||
document.head.appendChild(script);
|
||||
}, message);
|
||||
}
|
||||
|
||||
} // end of namespace gristUtils
|
||||
|
||||
stackWrapOwnMethods(gristUtils);
|
||||
|
||||
Reference in New Issue
Block a user