diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/document-metadata/the-style-element')
8 files changed, 197 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/.gitkeep b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/historical.html b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/historical.html new file mode 100644 index 000000000..d475f5b3c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/historical.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>Historical style element features should not be supported</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +function t(property) { + test(function() { + assert_false(property in document.createElement('style')); + }, 'style.' + property + ' should not be supported'); +} +// added in https://github.com/whatwg/html/commit/29cf39d2163cfc85b67409f4e10390619ffb2b40 +// removed in https://github.com/whatwg/html/commit/c2a3b2a2e3db49c14b486a5e99acf7d10cfe8443 +t('scoped'); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/html_style_in_comment-ref.html b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/html_style_in_comment-ref.html new file mode 100644 index 000000000..999383c76 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/html_style_in_comment-ref.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[style] Reference file</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<style> + h4 { + color: green; + } +</style> +<body> + <p> + This page tests that Style written inside HTML comment is not applied + </p> + This test passes if the text below is <b>Green. NOT Red.</b> + <h4> + This is some text. + </h4> +</body> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/html_style_in_comment.xhtml b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/html_style_in_comment.xhtml new file mode 100644 index 000000000..839548f01 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/html_style_in_comment.xhtml @@ -0,0 +1,18 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<link rel="match" href="html_style_in_comment-ref.html"/> +<style type="text/css"> +h4 {color: green} +<!-- +h4 {color: red} +--> +</style> +</head> +<body> +<p> This page tests that Style written inside HTML comment is not applied</p> +This test passes if the text below is <b>Green. NOT Red.</b> +<h4> +This is some text. +</h4> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style-error-01.html b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style-error-01.html new file mode 100644 index 000000000..87cb9fafd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style-error-01.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<title>style: error events</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<div id="test"> +<script> +//var t404 = async_test("Should get an error event for a 404 error.") +//t404.step(function() { +// var elt = document.createElement("style"); +// elt.onerror = t404.step_func(function() { +// assert_true(true, "Got error event for 404 error.") +// t404.done() +// }) +// elt.appendChild( +// document.createTextNode('@import 404 error;')); +// document.getElementsByTagName("head")[0].appendChild(elt); +//}) +var tText = async_test("Should get an error event for a text/plain response.") +tText.step(function() { + var elt = document.createElement("style"); + elt.onerror = tText.step_func(function() { + assert_true(true, "Got error event for 404 error.") + tText.done() + }) + elt.appendChild( + document.createTextNode('@import "../../../../common/css-red.txt";')); + document.getElementsByTagName("head")[0].appendChild(elt); +}) +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_disabled.html b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_disabled.html new file mode 100644 index 000000000..d26746a9c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_disabled.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>HTML Test: The style should not be applied if it is disabled</title> + <link rel="author" title="Intel" href="http://www.intel.com/"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <style> + #test { + width: 100px; + } + </style> + <style id="style"> + #test { + width: 50px; + } + </style> + </head> + <body> + <div id="log"></div> + <div id="test"></div> + <script> + test(function() { + var testElement = document.getElementById("test"); + var style = document.getElementById("style"); + var width1, width2; + + width1 = window.getComputedStyle(testElement, false)["width"]; + assert_equals(width1, "50px", "The style should be applied."); + + style.disabled = true; + width2 = window.getComputedStyle(testElement, false)["width"]; + assert_equals(width2, "100px", "The style should not be applied."); + }, "The style is not applied when it is disabled"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_events.html b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_events.html new file mode 100644 index 000000000..5e07e5088 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_events.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>HTML Test: The style events</title> + <link rel="author" title="Intel" href="http://www.intel.com/"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script> + var tLoad = async_test("If the style is loaded successfully, the 'load' event must be fired"); + var tError = async_test("If the style is loaded unsuccessfully, the 'error' event must be fired"); + + function onstyleload(e) { + tLoad.done(); + } + + function onstyleerror(e) { + tError.done(); + } + </script> + <style onload="onstyleload()"> + #test { + height: 100px; + width: 100px; + } + </style> + <style onerror="onstyleerror()"> + @import url(nonexistent.css); + </style> + </head> + <body> + <div id="log"></div> + <div id="test"></div> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_media.html b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_media.html new file mode 100644 index 000000000..5bd189a26 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-style-element/style_media.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>HTML Test: The style information must be applied to the environment specified by the media attribute</title> + <link rel="author" title="Intel" href="http://www.intel.com/"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-style-media"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <style> + #test { + width: 100px; + } + </style> + <style id="style"> + #test { + width: 50px; + } + </style> + </head> + <body> + <div id="log"></div> + <div id="test"></div> + <script> + test(function() { + var testElement = document.getElementById("test"); + var style = document.getElementById("style"); + var width1, width2; + + width1 = window.getComputedStyle(testElement, false)["width"]; + assert_equals(width1, "50px", "The style should be applied."); + + style.media = "print"; + width2 = window.getComputedStyle(testElement, false)["width"]; + assert_equals(width2, "100px", "The style should not be applied."); + }, "The style information must be applied to the environment specified by the media attribute"); + </script> + </body> +</html> |