Bug filed: https://bugs.webkit.org/show_bug.cgi?id=185906
This gist demonstrates an unexpected behavior in Safari after retrieving data from indexedDB inside an iframe: values cannot be properly checked against constructors with instanceof.
Tested on Safari Version 11.1 (13605.1.33.1.4) on macOS High Sierra 10.13.4.
Pseudo code that runs in an iframe:
const record = { array: [1, 2, 3] };
// Same record retrieved later from indexedDB:
const record = event.target.result;
record.array instanceof Array; // expected true but false in Safari 11.1
record.array instanceof window.parent.Array; // expected false but true in Safari 11.1
A lot of libraries and home-made code rely on instanceof to work as expected on values retrieved from indexedDB in an iframe.
Demo files:
ok-indexeddb-instanceof.html
: store and retrieve a record having Array and Uint8Array propertiesko-indexeddb-iframe.html
: same test run inside an iframe
Related issues:
Usage:
- Download this gist as a zip
- Start a local webserver (e.g.
python3 -m http.server
) - Open the .html files in Safari