Skip to content

Commit

Permalink
Fix incorrect tests for storage APIs in data: URL workers
Browse files Browse the repository at this point in the history
Removed localStorage test as localStorage is never exposed to workers.

IndexedDB spec will be updated to throw when used from opaque origins.
(w3c/IndexedDB#150)

Added a new test for webdatabase.

BUG=270979

Review-Url: https://codereview.chromium.org/2697003002
Cr-Commit-Position: refs/heads/master@{#450654}
  • Loading branch information
andypaicu authored and Commit bot committed Feb 15, 2017
1 parent 4e8c7f7 commit a97d645
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
// Communications goes both ways
assert_worker_sends_pass('communication goes both ways', 'application/javascript', 'port.onmessage = function(e) { port.postMessage("PASS"); }');

// 'data:' workers are cross-origin
// test access to storage APIs
// once https://github.com/w3c/IndexedDB/pull/150 lands, this is spec conforming
assert_worker_throws('indexedDB inaccessible', 'self.indexedDB.open("someDBName")');
assert_worker_throws('localStorage inaccessible', 'self.localStorage.testItem');
assert_worker_sends_pass('cross-origin worker', '', 'fetch("/").then(() => port.postMessage("FAIL"), () => port.postMessage("PASS"))');
assert_worker_throws('Web SQL Database inaccessible', 'self.openDatabase("someDBName", "1.0", "someDBName", 1);');

// 'data:' workers are cross-origin
assert_worker_sends_pass('cross-origin worker', '', 'fetch("/").then(() => port.postMessage("FAIL"), () => port.postMessage("PASS"))');
// 'data:' workers have opaque origin
assert_worker_sends_pass('worker has opaque origin', 'application/javascript', 'if (self.location.origin == "null") port.postMessage("PASS"); else port.postMessage("FAIL");');
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@
// Communications goes both ways
assert_worker_sends_pass('communication goes both ways', 'application/javascript', 'onmessage = function(e) { self.postMessage("PASS"); }');

// 'data:' workers are cross-origin
// test access to storage APIs
// once https://github.com/w3c/IndexedDB/pull/150 lands, this is spec conforming
assert_worker_throws('indexedDB inaccessible', 'self.indexedDB.open("someDBName")');
assert_worker_throws('localStorage inaccessible', 'self.localStorage.testItem');
assert_worker_throws('Web SQL Database inaccessible', 'self.openDatabase("someDBName", "1.0", "someDBName", 1);');

// 'data:' workers are cross-origin
assert_worker_sends_pass('cross-origin worker', '', 'fetch("/").then(() => self.postMessage("FAIL"), () => self.postMessage("PASS"))');

// 'data:' workers have opaque origin
Expand Down

0 comments on commit a97d645

Please sign in to comment.