mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-03 15:41:57 +00:00
This was preventing https://ubereats.com/ from fully loading, because they are attempting to overwrite setItem. They seem to be trying to add error logging to setItem if it throws, as all they do is add a try/catch block that emits an error log to their monitoring service if it throws. However, because Storage is a legacy platform object with a named property setter (setItem), it will call setItem with the stringified version of the function. This is actually expected as per the spec, Firefox (Gecko) and Epiphany (WebKit) does this too, but Chromium does not as it actually overwrites the function with the new function and does not store the stringified function. The problem is that we had the LegacyOverrideBuiltIns flag accidentally set, so it would return the stored string instead of the built-in function (hence the name), then it would try and call it and throw a "not a function" error. This prevented their JS from going any further. This fix allows their UI to fully load and be fully interactive, though it is quite slow at the moment!
14 lines
670 B
HTML
14 lines
670 B
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
for (const functionName of ["key", "getItem", "setItem", "removeItem", "clear"]) {
|
|
const failFunction = function () { println(`FAIL: Overriden ${functionName} was called`); };
|
|
window.localStorage[functionName] = failFunction;
|
|
|
|
println(`${functionName} should still be native: '${window.localStorage[functionName].toString()}'`);
|
|
println(`${functionName}'s stringified function was added to storage: '${window.localStorage.getItem(functionName)}'`);
|
|
window.localStorage[functionName]("1", "2");
|
|
}
|
|
});
|
|
</script>
|