Skip to content

Commit

Permalink
Expose kv-storage built-in module only on SecureContexts
Browse files Browse the repository at this point in the history
This CL adds actual restriction in Blink implementation.

This CL also modifies tests and expectations to match with
the current Blink built-in/import maps infra.

A subtest in WPT test `import-statement.html` is failing
because the current Blink implementation is based on
pre-import-map spec and thus
importing unavailable built-in causes fetch error.
See 'import 'std:nonexistent';' row of
WICG/import-maps#159.

Bug: 977470
Change-Id: I107f60ed95e1f91d62f468c29c5d741eef13f4f9
  • Loading branch information
hiroshige-g authored and chromium-wpt-export-bot committed Aug 26, 2019
1 parent 23f463a commit 9fff1aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions kv-storage/secure-context/import-maps.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script type="importmap">
{
"imports": {
"std:kv-storage": [
"./resources/dummy-module.js": [
"std:kv-storage",
"./resources/dummy-module.js"
]
Expand All @@ -25,7 +25,7 @@

<script type="module">
promise_test(async () => {
const result = await import("std:kv-storage");
assert_equals(namespaceObj.myExport, "not the real KV storage");
const result = await import("./resources/dummy-module.js");
assert_equals(result.myExport, "not the real KV storage");
});
</script>
13 changes: 7 additions & 6 deletions kv-storage/secure-context/import-statement.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
assert_false(self.isSecureContext, "This test must run in a non-secure context");
}, "Prerequisite check");

async_test(t => {
window.addEventListener("error", t.step_func_done(errorEvent => {
assert_equals(errorEvent.error.constructor, TypeError, "Must trigger a TypeError");
}, { once: true }));
});
const t = async_test('Static import kv-storage in non-secure context');

window.addEventListener("error", t.step_func_done(errorEvent => {
assert_equals(errorEvent.error.constructor, TypeError, "Must trigger a TypeError");
}, { once: true }));
</script>

<script type="module">
<script type="module"
onerror="t.unreached_func('script error event should not be fired')()">
import "std:kv-storage";
</script>

0 comments on commit 9fff1aa

Please sign in to comment.