New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 769012 link

Starred by 24 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 1
Type: Bug

Blocked on:
issue 797712



Sign in to add a comment

Modules don't work in extensions

Project Member Reported by rdevlin....@chromium.org, Sep 26 2017

Issue description

What steps will reproduce the problem?
1. Load an extension with the content below.

What is the expected result?
The extension should load without error (and should have access to the module).

What happens instead of that?
The module fails to load and gives the error:
"Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec."

---  Extension  ---
// manifest.json
{
  "name": "foo",
  "description": "bar",
  "version": "0.1",
  "background": {"page": "background.html"}
  "manifest_version": 2
}

// background.html
<!doctype html>
<html>
<script src="background.js" type="module"></script>
</html>

// background.js
import {log} from '/module.js'
log('hi');

// module.js
export function log(data) { console.log(data); }

 
Project Member

Comment 1 by bugdroid1@chromium.org, Sep 28 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6449de840aec46116c234a5865c4ba120a0e38d9

commit 6449de840aec46116c234a5865c4ba120a0e38d9
Author: Devlin Cronin <rdevlin.cronin@chromium.org>
Date: Thu Sep 28 03:28:51 2017

[Extensions] Include mime type in served extension files

Modules enforce strict mime type requirements, but files served through
extension protocols don't specify a mime type. Include it in the
response headers. This enables modules for chrome extensions.

Add a test to exercise basic module use.

Bug:  769012 
Change-Id: I1eba64e9194c00b9feb39f5fb0f5576a53d34930
Reviewed-on: https://chromium-review.googlesource.com/685802
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504885}
[add] https://crrev.com/6449de840aec46116c234a5865c4ba120a0e38d9/chrome/browser/extensions/extension_modules_apitest.cc
[modify] https://crrev.com/6449de840aec46116c234a5865c4ba120a0e38d9/chrome/test/BUILD.gn
[add] https://crrev.com/6449de840aec46116c234a5865c4ba120a0e38d9/chrome/test/data/extensions/api_test/modules/background.html
[add] https://crrev.com/6449de840aec46116c234a5865c4ba120a0e38d9/chrome/test/data/extensions/api_test/modules/background.js
[add] https://crrev.com/6449de840aec46116c234a5865c4ba120a0e38d9/chrome/test/data/extensions/api_test/modules/manifest.json
[add] https://crrev.com/6449de840aec46116c234a5865c4ba120a0e38d9/chrome/test/data/extensions/api_test/modules/module.js
[modify] https://crrev.com/6449de840aec46116c234a5865c4ba120a0e38d9/extensions/browser/extension_protocols.cc

Comment 2 by kouhei@chromium.org, Sep 28 2017

Cc: hirosh...@chromium.org
cc: hiroshige
I think we only need to special case file URLs then.
Status: Fixed (was: Started)

Comment 4 by liuhao...@gmail.com, Nov 15 2017

Test failed on 64.0.3268.0 (Official Build) canary (64-bit) (cohort: Clang-64)

Comment 5 by liuhao...@gmail.com, Nov 22 2017

Can reproduce this issue on chrome 64.0.3275.0 (Official Build) canary (64-bit) (cohort: Clang-64).

Why this issue status is fixed? 
Firefox has the same (or a very similar) bug. If you want script modules to also work in Firefox extensions, you can vote here: https://bugzilla.mozilla.org/show_bug.cgi?id=1404727
This bug seems to be a duplicate of https://bugs.chromium.org/p/chromium/issues/detail?id=769012
#c7 did you mean to link to a different issue?
#c8 yes, thanks for pointing out! this is the issue I wanted to refer to:
https://bugs.chromium.org/p/chromium/issues/detail?id=763673
Re #5: The fix for this issue landed in 63.0.3227.0. If you can still reproduce this issue, please provide a test case.
Cc: kouhei@chromium.org pnangunoori@chromium.org
 Issue 763673  has been merged into this issue.
Re #10: there is an old issue https://bugs.chromium.org/p/chromium/issues/detail?id=762483#c18 (#c18 find out the reason and give a way to resovle this problem, but this issue mark as won't fix. and now this issue has a wide impact on modules/local-files, consider to deal this suitable, not ignore)
Recent discussions: https://bugs.chromium.org/p/chromium/issues/detail?id=728377#c23 ~ #c30 (there is no following)
Blockedon: 797712
Components: Blink>HTML>Script
Thanks for heads up. Filed a new  Issue 797712  for tracking the particular issue caused by the local registry key.

(Leaving this issue closed as fixed, because the basic module script+extention issue has been fixed.)
Project Member

Comment 16 by bugdroid1@chromium.org, May 4 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/17d521bb5afbcc8d6ee95b46a4565351aee6d4fd

commit 17d521bb5afbcc8d6ee95b46a4565351aee6d4fd
Author: Istiaque Ahmed <lazyboy@chromium.org>
Date: Fri May 04 19:44:07 2018

Extensions: Add a test for importing modules from web

Bug:  769012 
Change-Id: Iae7e7ff1b338c2302476002c28dcc58378292404
Reviewed-on: https://chromium-review.googlesource.com/1028617
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556156}
[modify] https://crrev.com/17d521bb5afbcc8d6ee95b46a4565351aee6d4fd/chrome/browser/extensions/extension_modules_apitest.cc
[add] https://crrev.com/17d521bb5afbcc8d6ee95b46a4565351aee6d4fd/chrome/test/data/extensions/api_test/module_from_web/hello_module.js

Cc: rdevlin....@chromium.org mkwst@chromium.org mmenke@chromium.org davidben@chromium.org falken@chromium.org rsleevi@chromium.org asanka@chromium.org jbroman@chromium.org
 Issue 728377  has been merged into this issue.

Sign in to add a comment