WebKit Bugzilla
Attachment 341118 Details for
Bug 185906
: Unexpected constructor / instanceof behavior when retrieving indexedDB data in an iframe
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Minimal test case
idb_bug.html (text/html), 1.87 KB, created by
John Vilk
on 2018-05-23 12:49:45 PDT
(
hide
)
Description:
Minimal test case
Filename:
MIME Type:
Creator:
John Vilk
Created:
2018-05-23 12:49:45 PDT
Size:
1.87 KB
patch
obsolete
><!doctype html> ><html> > <script type="text/javascript"> > window.onload = function() { > function test(cb) { > const testdb = indexedDB.open('testdb', 1); > testdb.onupgradeneeded = function() { > const db = testdb.result; > db.createObjectStore("TestObjects", {keyPath: "id"}); > }; > testdb.onsuccess = function() { > const db = testdb.result; > const tx = db.transaction("TestObjects", "readwrite"); > const store = tx.objectStore("TestObjects"); > > // Add some data > store.put({id: 12345, array: [1,2,3,4,5], arrayBuffer: new ArrayBuffer(10) }); > > // Query the data > const getTestData = store.get(12345); > getTestData.onsuccess = function() { > const result = getTestData.result; > console.log("result.array instanceof Array: " + (result.array instanceof Array)); > console.log("result.array instanceof window.top.Array: " + (result.array instanceof window.top.Array)); > console.log("Array.isArray(result.array): " + Array.isArray(result.array)); > console.log("result.arrayBuffer instanceof ArrayBuffer: " + (result.arrayBuffer instanceof ArrayBuffer)); > console.log("result.arrayBuffer instanceof window.top.ArrayBuffer: " + (result.arrayBuffer instanceof window.top.ArrayBuffer)); > }; > tx.oncomplete = function() { > db.close(); > cb(); > }; > }; > } > > console.log(`Testing in main context!`); > test(function() { > const ifr = document.createElement('iframe'); > ifr.srcdoc = `<!doctype html><html><script type="text/javascript">${test.toString()} console.log("Testing in iframe context!"); test(function() { console.log("test complete."); });</` + `script></html>`; > document.body.appendChild(ifr); > }); > }; > </script> ></html>
<!doctype html> <html> <script type="text/javascript"> window.onload = function() { function test(cb) { const testdb = indexedDB.open('testdb', 1); testdb.onupgradeneeded = function() { const db = testdb.result; db.createObjectStore("TestObjects", {keyPath: "id"}); }; testdb.onsuccess = function() { const db = testdb.result; const tx = db.transaction("TestObjects", "readwrite"); const store = tx.objectStore("TestObjects"); // Add some data store.put({id: 12345, array: [1,2,3,4,5], arrayBuffer: new ArrayBuffer(10) }); // Query the data const getTestData = store.get(12345); getTestData.onsuccess = function() { const result = getTestData.result; console.log("result.array instanceof Array: " + (result.array instanceof Array)); console.log("result.array instanceof window.top.Array: " + (result.array instanceof window.top.Array)); console.log("Array.isArray(result.array): " + Array.isArray(result.array)); console.log("result.arrayBuffer instanceof ArrayBuffer: " + (result.arrayBuffer instanceof ArrayBuffer)); console.log("result.arrayBuffer instanceof window.top.ArrayBuffer: " + (result.arrayBuffer instanceof window.top.ArrayBuffer)); }; tx.oncomplete = function() { db.close(); cb(); }; }; } console.log(`Testing in main context!`); test(function() { const ifr = document.createElement('iframe'); ifr.srcdoc = `<!doctype html><html><script type="text/javascript">${test.toString()} console.log("Testing in iframe context!"); test(function() { console.log("test complete."); });</` + `script></html>`; document.body.appendChild(ifr); }); }; </script> </html>
View Attachment As Raw
Actions:
View
Attachments on
bug 185906
: 341118 |
355815