-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1592868 [wpt PR 20012] - [SyntheticModules] Implements CSS Module…
…s, a=testonly Automatic update from web-platform-tests [SyntheticModules] Implements CSS Modules This is the final change required for CSS Modules to be utilized by developers. Following the acceptance of this change, if you run chromium with the CSSModules runtime flag, the following is now valid syntax: <script type="module"> import sheet from "./example.css"; </script> CSS Modules Explainer: https://github.com/w3c/webcomponents/blob/gh-pages/proposals/css-modules-v1-explainer.md CSS Modules Spec PR: whatwg/html#4898 Bug: 967018 Change-Id: Ifdee5b92259fb7e4e9c8f9aa88e69a98eb55c551 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1799923 Commit-Queue: Sam Sebree <[email protected]> Reviewed-by: Hiroshige Hayashizaki <[email protected]> Reviewed-by: Kouhei Ueno <[email protected]> Reviewed-by: Hiroki Nakagawa <[email protected]> Reviewed-by: Yuki Shiino <[email protected]> Cr-Commit-Position: refs/heads/master@{#724896} -- wpt-commits: 6fbd872e9ac5fe60e32946bc9b318be6eeada123 wpt-pr: 20012
- Loading branch information
1 parent
21dcc77
commit 07955d2
Showing
12 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...ests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
setup({allow_uncaught_exception: true}); | ||
async_test(function (test) { | ||
const worker = new Worker("./resources/worker.js", { | ||
type: "module" | ||
}); | ||
worker.onmessage = test.unreached_func("A CSS Module within a web worker should not load."); | ||
worker.onerror = test.step_func_done(); | ||
}, "A static import CSS Module within a web worker should not load."); | ||
|
||
async_test(function (test) { | ||
const worker = new Worker("./resources/worker-dynamic-import.js", { | ||
type: "module" | ||
}); | ||
worker.onmessage = test.step_func_done(e => { | ||
assert_equals(e.data, "NOT LOADED"); | ||
}); | ||
}, "A dynamic import CSS Module within a web worker should not load."); | ||
|
||
async_test(function (test) { | ||
const worker = new Worker("./resources/basic.css", { | ||
type: "module" | ||
}); | ||
worker.onerror = test.step_func_done(); | ||
}, "A CSS Module within a web worker should not load."); | ||
|
||
</script> | ||
|
||
</body> |
44 changes: 44 additions & 0 deletions
44
...sts/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
async_test(function (test) { | ||
const iframe = document.createElement("iframe"); | ||
iframe.src = "resources/css-module-basic-iframe.html"; | ||
iframe.onload = test.step_func_done(function () { | ||
assert_equals(getComputedStyle(iframe.contentDocument.querySelector('#test')) | ||
.backgroundColor, "rgb(255, 0, 0)", | ||
"CSS module import should succeed"); | ||
}); | ||
document.body.appendChild(iframe); | ||
}, "A CSS Module should load"); | ||
|
||
async_test(function (test) { | ||
const iframe = document.createElement("iframe"); | ||
iframe.src = "resources/css-module-at-import-iframe.html"; | ||
iframe.onload = test.step_func_done(function () { | ||
assert_equals(iframe.contentDocument.load_error, "NotAllowedError"); | ||
assert_not_equals(getComputedStyle(iframe.contentDocument.querySelector('#test')) | ||
.backgroundColor, "rgb(255, 0, 0)", | ||
"CSS module @import should not succeed"); | ||
}); | ||
document.body.appendChild(iframe); | ||
}, "An @import CSS Module should not load"); | ||
|
||
async_test(function (test) { | ||
const iframe = document.createElement("iframe"); | ||
iframe.src = "resources/malformed-iframe.html"; | ||
iframe.onload = test.step_func_done(function () { | ||
assert_not_equals(getComputedStyle(iframe.contentDocument.querySelector('#test')) | ||
.backgroundColor, "rgb(255, 0, 0)", | ||
"Malformed CSS should not load"); | ||
}); | ||
document.body.appendChild(iframe); | ||
}, "Malformed CSS should not load"); | ||
</script> | ||
</body> |
1 change: 1 addition & 0 deletions
1
...m/tests/html/semantics/scripting-1/the-script-element/css-module/resources/bad-import.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import "basic.css" |
3 changes: 3 additions & 0 deletions
3
...atform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/basic.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#test { | ||
background-color:red; | ||
} |
18 changes: 18 additions & 0 deletions
18
...tics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script> | ||
window.onerror = function (errorMsg, url, lineNumber, column, errorObj) | ||
{ | ||
document.load_error = errorObj.name; | ||
return true; | ||
}; | ||
</script> | ||
<script type="module"> | ||
import v from "./bad-import.css"; | ||
document.adoptedStyleSheets = [v]; | ||
</script> | ||
|
||
<div id="test"> | ||
I am a test div. | ||
</div> | ||
</body> |
18 changes: 18 additions & 0 deletions
18
...emantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script> | ||
window.onerror = function (errorMsg, url, lineNumber, column, errorObj) | ||
{ | ||
document.load_error = errorObj.name; | ||
return true; | ||
}; | ||
</script> | ||
<script type="module"> | ||
import v from "./basic.css"; | ||
document.adoptedStyleSheets = [v]; | ||
</script> | ||
|
||
<div id="test"> | ||
I am a test div. | ||
</div> | ||
</body> |
11 changes: 11 additions & 0 deletions
11
.../html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script type="module"> | ||
import v from "./malformed.css"; | ||
document.adoptedStyleSheets = [v]; | ||
</script> | ||
|
||
<div id="test"> | ||
I am a test div. | ||
</div> | ||
</body> |
3 changes: 3 additions & 0 deletions
3
...rm/tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#test {{ | ||
background-color:red; | ||
} |
3 changes: 3 additions & 0 deletions
3
...latform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/utf8.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#test { | ||
content: "…"; | ||
} |
3 changes: 3 additions & 0 deletions
3
...ml/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import("./basic.css") | ||
.then(() => postMessage("LOADED")) | ||
.catch(e => postMessage("NOT LOADED")); |
2 changes: 2 additions & 0 deletions
2
...atform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import "./basic.css"; | ||
postMessage("Unexpectedly loaded"); |
34 changes: 34 additions & 0 deletions
34
...atform/tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>CSS modules: UTF-8 decoding</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
function check(t, v) { | ||
t.step(() => { | ||
assert_equals(typeof v, "object"); | ||
assert_equals(v.rules[0].style.content, "\"…\""); | ||
t.done(); | ||
}); | ||
} | ||
const t1 = async_test("utf-8"); | ||
const t2 = async_test("shift-jis"); | ||
const t3 = async_test("windows-1252"); | ||
const t4 = async_test("utf-7"); | ||
</script> | ||
<script type="module" onerror="t1.step(() => assert_unreached(event))"> | ||
import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=utf-8"; | ||
check(t1, v); | ||
</script> | ||
<script type="module" onerror="t2.step(() => assert_unreached(event))"> | ||
import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=shift-jis"; | ||
check(t2, v); | ||
</script> | ||
<script type="module" onerror="t3.step(() => assert_unreached(event))"> | ||
import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=windows-1252"; | ||
check(t3, v); | ||
</script> | ||
<script type="module" onerror="t4.step(() => assert_unreached(event))"> | ||
import v from "../serve-with-content-type.py?fn=css-module/resources/utf8.css&ct=text/css%3Bcharset=utf-7"; | ||
check(t4, v); | ||
</script> |