diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/html/semantics/embedded-content | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content')
476 files changed, 13254 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/dimension-attributes/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/dimension-attributes/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/dimension-attributes/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/image-maps/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/image-maps/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/image-maps/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/image-maps/contains.json b/testing/web-platform/tests/html/semantics/embedded-content/image-maps/contains.json new file mode 100644 index 000000000..77e0d34fa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/image-maps/contains.json @@ -0,0 +1,10 @@ +[ + { + "id": "authoring", + "original_id": "authoring" + }, + { + "id": "processing-model-0", + "original_id": "processing-model-0" + } +]
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/mathml/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/mathml/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/mathml/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_controls_present-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_controls_present-manual.html new file mode 100644 index 000000000..38faa4d00 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_controls_present-manual.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> + <head> + <title>Audio Test: audio_controls_present.html</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-controls" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the controls attribute is present in the audio element that expecting the user agent exposes a controller user interface" /> + </head> + <body> + <p>Test passes if a controller user interface appears below and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <audio id="m" controls>The user agent doesn't support media element.</audio> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_loop_base.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_loop_base.html new file mode 100644 index 000000000..4917d9c39 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_loop_base.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html> + <head> + <title>Audio Test: audio_loop_base</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-loop" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if audio.loop is set to true that expecting the seeking event is fired more than once" /> + <meta name=timeout content=long> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <div id="log"></div> + <audio id="m" controls>The user agent doesn't support media element.</audio> + <script type="text/javascript"> + var media = document.getElementById("m"); + var name = document.getElementsByName("assert")[0].content; + var t = async_test(name); + + var looped = false; + + function startTest() { + if (looped) { + t.step(function() { + assert_true(true, "looped"); + }); + t.done(); + media.pause(); + } + + looped = true; + } + + media.addEventListener("seeking", startTest, false); + media.loop = true; + media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_muted_overriding_volume-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_muted_overriding_volume-manual.html new file mode 100644 index 000000000..cc1892ce8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_muted_overriding_volume-manual.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> + <head> + <title>Audio Test: audio_muted_overriding_volume</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-muted" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the muted attribute is present in the audio element with volume is set to loudest that expecting the user hears no sound" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the audio is playing without sound output and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <audio id="m" controls muted>The user agent doesn't support media element.</audio> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + media.volume = 1.0; + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_muted_present-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_muted_present-manual.html new file mode 100644 index 000000000..16d6f07ee --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_muted_present-manual.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> + <head> + <title>Audio Test: audio_muted_present</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-muted" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the muted attribute is present in the audio element that expecting the user hears no sound" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the audio is playing without sound output and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <audio id="m" controls muted>The user agent doesn't support media element.</audio> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_check.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_check.html new file mode 100644 index 000000000..b467c702a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_check.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<html> + <head> + <title>Audio Test: audio_volume_check</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check that audio.volume returns the value of the muted content attribute" /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id="log"></div> + <audio id="m">The user agent doesn't support media element.</audio> + <script type="text/javascript"> + var media = document.getElementById("m"); + var VOLUME = { + 'SILENT' : 0.0, + 'NORMAL' : 0.5, + 'LOUDEST' : 1.0, + 'LOWER' : -1.1, + 'UPPER' : 1.1, + }; + + test(function() { + assert_false(media.volume < VOLUME.SILENT || media.volume > VOLUME.LOUDEST, "media.volume outside the range 0.0 to 1.0 inclusive"); + }, "Check if the intial value of the audio.volume is in the range 0.0 to 1.0 inclusive"); + + function volume_setting(vol, name) + { + if (vol < VOLUME.SILENT || vol > VOLUME.LOUDEST) { + try { + media.volume = vol; + test(function() { + assert_true(false, "media.volume setting exception"); + }, name); + } catch(e) { + test(function() { + // 1 should be e.IndexSizeError or e.INDEX_SIZE_ERR in previous spec + assert_equals(e.code, 1, "media.volume setting exception"); + }, name); + } + } else { + media.volume = vol; + test(function() { + assert_equals(media.volume, vol, "media.volume new value"); + }, name); + } + } + + volume_setting(VOLUME.NORMAL, "Check if audio.volume is able to set to new value in the range 0.0 to 1.0"); + volume_setting(VOLUME.SILENT, "Check if media.volume is able to set to new value 0.0 as silent"); + volume_setting(VOLUME.LOUDEST, "Check if media.volume is able to set to new value 1.0 as loudest"); + volume_setting(VOLUME.LOWER, "Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown"); + volume_setting(VOLUME.UPPER, "Check if audio.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_loudest-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_loudest-manual.html new file mode 100644 index 000000000..a623e8f5c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_loudest-manual.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> + <head> + <title>Audio Test: audio_volume_loudest</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the volume attribute is set to 1.0 as loudest in the audio element that expecting the user hears sound loudly" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the audio is playing with sound heard and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <audio id="m" controls>The user agent doesn't support media element.</audio> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + media.volume = 1.0; + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_silent-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_silent-manual.html new file mode 100644 index 000000000..257bd4628 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/audio_volume_silent-manual.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> + <head> + <title>Audio Test: audio_volume_silent</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the volume attribute is set to 0.0 as silent in the audio element that expecting the user hears no sound" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the audio is playing without sound heard and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <audio id="m" controls volume=0.0>The user agent doesn't support media element.</audio> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + media.volume = 0.0; + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/contains.json b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/contains.json new file mode 100644 index 000000000..9cf23296c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/contains.json @@ -0,0 +1,132 @@ +[ + { + "id": "error-codes", + "original_id": "error-codes" + }, + { + "id": "location-of-the-media-resource", + "original_id": "location-of-the-media-resource" + }, + { + "id": "mime-types", + "original_id": "mime-types" + }, + { + "id": "network-states", + "original_id": "network-states" + }, + { + "id": "loading-the-media-resource", + "original_id": "loading-the-media-resource" + }, + { + "id": "offsets-into-the-media-resource", + "original_id": "offsets-into-the-media-resource" + }, + { + "id": "ready-states", + "original_id": "ready-states" + }, + { + "id": "playing-the-media-resource", + "original_id": "playing-the-media-resource" + }, + { + "id": "seeking", + "original_id": "seeking" + }, + { + "id": "media-resources-with-multiple-media-tracks", + "original_id": "media-resources-with-multiple-media-tracks", + "children": [ + { + "id": "audiotracklist-and-videotracklist-objects", + "original_id": "audiotracklist-and-videotracklist-objects" + }, + { + "id": "selecting-specific-audio-and-video-tracks-declaratively", + "original_id": "selecting-specific-audio-and-video-tracks-declaratively" + } + ] + }, + { + "id": "synchronising-multiple-media-elements", + "original_id": "synchronising-multiple-media-elements", + "children": [ + { + "id": "introduction-0", + "original_id": "introduction-0" + }, + { + "id": "media-controllers", + "original_id": "media-controllers" + }, + { + "id": "assigning-a-media-controller-declaratively", + "original_id": "assigning-a-media-controller-declaratively" + } + ] + }, + { + "id": "timed-text-tracks", + "original_id": "timed-text-tracks", + "children": [ + { + "id": "text-track-model", + "original_id": "text-track-model" + }, + { + "id": "sourcing-in-band-text-tracks", + "original_id": "sourcing-in-band-text-tracks" + }, + { + "id": "sourcing-out-of-band-text-tracks", + "original_id": "sourcing-out-of-band-text-tracks" + }, + { + "id": "guidelines-for-exposing-cues-in-various-formats-as-text-track-cues", + "original_id": "guidelines-for-exposing-cues-in-various-formats-as-text-track-cues" + }, + { + "id": "text-track-api", + "original_id": "text-track-api" + }, + { + "id": "text-tracks-describing-chapters", + "original_id": "text-tracks-describing-chapters" + }, + { + "id": "cue-events", + "original_id": "cue-events" + } + ] + }, + { + "id": "user-interface", + "original_id": "user-interface" + }, + { + "id": "time-ranges", + "original_id": "time-ranges" + }, + { + "id": "event-definitions", + "original_id": "event-definitions" + }, + { + "id": "mediaevents", + "original_id": "mediaevents" + }, + { + "id": "security-and-privacy-considerations", + "original_id": "security-and-privacy-considerations" + }, + { + "id": "best-practices-for-authors-using-media-elements", + "original_id": "best-practices-for-authors-using-media-elements" + }, + { + "id": "best-practices-for-implementors-of-media-elements", + "original_id": "best-practices-for-implementors-of-media-elements" + } +] diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/error-codes/error.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/error-codes/error.html new file mode 100644 index 000000000..c97576041 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/error-codes/error.html @@ -0,0 +1,38 @@ +<!doctype html> +<title>error</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id="log"></div> +<script> +function error_test(tagName, src) { + test(function() { + assert_equals(document.createElement(tagName).error, null); + }, tagName + '.error initial value'); + + async_test(function(t) { + var e = document.createElement(tagName); + e.src = src; + e.onloadeddata = t.step_func(function() { + assert_equals(e.error, null); + t.done(); + }); + }, tagName + '.error after successful load'); + + // TODO: MEDIA_ERR_ABORTED, MEDIA_ERR_NETWORK, MEDIA_ERR_DECODE + + async_test(function(t) { + var e = document.createElement(tagName); + e.src = ''; + e.onerror = t.step_func(function() { + assert_true(e.error instanceof MediaError); + assert_equals(e.error.code, 4); + assert_equals(e.error.code, e.error.MEDIA_ERR_SRC_NOT_SUPPORTED); + t.done(); + }); + }, tagName + '.error after setting src to the empty string'); +} + +error_test('audio', getAudioURI('/media/sound_5')); +error_test('video', getVideoURI('/media/movie_5')); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplay.html new file mode 100644 index 000000000..8e1b32dcb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplay.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - canplay</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger canplay event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("canplay", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - canplay"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger canplay event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("canplay", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - canplay"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplay_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplay_noautoplay.html new file mode 100644 index 000000000..8f3372501 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplay_noautoplay.html @@ -0,0 +1,36 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - canplay</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function () { + var t = async_test("setting src attribute on non-autoplay audio should trigger canplay event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("canplay", function() { + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - canplay"); + +test(function () { + var t = async_test("setting src attribute on non-autoplay video should trigger canplay event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("canplay", function() { + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - canplay"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplaythrough.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplaythrough.html new file mode 100644 index 000000000..827e79607 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplaythrough.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - canplaythrough</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger canplaythrough event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("canplaythrough", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - canplaythrough"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger canplaythrough event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("canplaythrough", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - canplaythrough"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplaythrough_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplaythrough_noautoplay.html new file mode 100644 index 000000000..75a70985a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_canplaythrough_noautoplay.html @@ -0,0 +1,36 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - canplaythrough</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on non-autoplay audio should trigger canplaythrough event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("canplaythrough", function() { + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - canplaythrough"); + +test(function() { + var t = async_test("setting src attribute on non-autoplay video should trigger canplaythrough event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("canplaythrough", function() { + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - canplaythrough"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadeddata.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadeddata.html new file mode 100644 index 000000000..f0e89c3c1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadeddata.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadeddata</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger loadeddata event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadeddata", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadeddata"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger loadeddata event", {timeout:5000}); + var a = document.getElementById("v"); + v.addEventListener("loadeddata", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - loadeddata"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadeddata_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadeddata_noautoplay.html new file mode 100644 index 000000000..0c81f335b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadeddata_noautoplay.html @@ -0,0 +1,36 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadeddata</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on non-autoplay audio should trigger loadeddata event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadeddata", function() { + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadeddata"); + +test(function() { + var t = async_test("setting src attribute on non-autoplay video should trigger loadeddata event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("loadeddata", function() { + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - loadeddata"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadedmetadata.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadedmetadata.html new file mode 100644 index 000000000..234121e58 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadedmetadata.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadedmetadata</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger loadedmetadata event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadedmetadata", function() { + t.done(); + a.pause(); + }); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadedmetadata"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger loadedmetadata event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("loadedmetadata", function() { + t.done(); + v.pause(); + }); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - loadedmetadata"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadedmetadata_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadedmetadata_noautoplay.html new file mode 100644 index 000000000..382f3f6fb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadedmetadata_noautoplay.html @@ -0,0 +1,36 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadedmetadata</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on non-autoplay audio should trigger loadedmetadata event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadedmetadata", function() { + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadedmetadata"); + +test(function() { + var t = async_test("setting src attribute on non-autoplay video should trigger loadedmetadata event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("loadedmetadata", function() { + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events, loadedmetadata"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadstart.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadstart.html new file mode 100644 index 000000000..de4568212 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadstart.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadstart</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger loadstart event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadstart", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadstart"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger loadstart event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("loadstart", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - loadstart"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadstart_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadstart_noautoplay.html new file mode 100644 index 000000000..b575e7ac8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_loadstart_noautoplay.html @@ -0,0 +1,36 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadstart</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on non-autoplay audio should trigger loadstart event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadstart", function() { + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadstart"); + +test(function() { + var t = async_test("setting src attribute on non-autoplay video should trigger loadstart event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("loadstart", function() { + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - loadstart"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_canplay_canplaythrough.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_canplay_canplaythrough.html new file mode 100644 index 000000000..a1e7e4155 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_canplay_canplaythrough.html @@ -0,0 +1,52 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - canplay, then canplaythrough</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger canplay then canplaythrough event", {timeout:5000}); + var a = document.getElementById("a"); + var found_canplay = false; + a.addEventListener("canplay", function() { + found_canplay = true; + }); + a.addEventListener("canplaythrough", function() { + t.step(function() { + assert_true(found_canplay); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - canplay, then canplaythrough"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger canplay then canplaythrough event", {timeout:5000}); + var v = document.getElementById("v"); + var found_canplay = false; + v.addEventListener("canplay", function() { + found_canplay = true; + }); + v.addEventListener("canplaythrough", function() { + t.step(function() { + assert_true(found_canplay); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - canplay, then canplaythrough"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_canplay_playing.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_canplay_playing.html new file mode 100644 index 000000000..a5a67ddb2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_canplay_playing.html @@ -0,0 +1,52 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - canplay, then playing</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger canplay then playing event", {timeout:5000}); + var a = document.getElementById("a"); + var found_canplay = false; + a.addEventListener("canplay", function() { + found_canplay = true; + }); + a.addEventListener("playing", function() { + t.step(function() { + assert_true(found_canplay); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - canplay, then playing"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger canplay then playing event", {timeout:5000}); + var v = document.getElementById("v"); + var found_canplay = false; + v.addEventListener("canplay", function() { + found_canplay = true; + }); + v.addEventListener("playing", function() { + t.step(function() { + assert_true(found_canplay); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - canplay, then playing"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_loadedmetadata_loadeddata.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_loadedmetadata_loadeddata.html new file mode 100644 index 000000000..3aba3684f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_loadedmetadata_loadeddata.html @@ -0,0 +1,52 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadedmetadata, then loadeddata</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger loadedmetadata then loadeddata event", {timeout:5000}); + var a = document.getElementById("a"); + var found_loadedmetadata = false; + a.addEventListener("loadedmetadata", function() { + found_loadedmetadata = true; + }); + a.addEventListener("loadeddata", function() { + t.step(function() { + assert_true(found_loadedmetadata); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadedmetadata, then loadeddata"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger loadedmetadata then loadeddata event", {timeout:5000}); + var v = document.getElementById("v"); + var found_loadedmetadata = false; + v.addEventListener("loadedmetadata", function() { + found_loadedmetadata = true; + }); + v.addEventListener("loadeddata", function() { + t.step(function() { + assert_true(found_loadedmetadata); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - loadedmetadata, then loadeddata"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_loadstart_progress.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_loadstart_progress.html new file mode 100644 index 000000000..75e3ba772 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_order_loadstart_progress.html @@ -0,0 +1,52 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - loadstart, then progress</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger loadstart then progress event", {timeout:5000}); + var a = document.getElementById("a"); + var found_loadstart = false; + a.addEventListener("loadstart", function() { + found_loadstart = true; + }); + a.addEventListener("progress", function() { + t.step(function() { + assert_true(found_loadstart); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - loadstart, then progress"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger loadstart then progress event", {timeout:5000}); + var v = document.getElementById("v"); + var found_loadstart = false; + v.addEventListener("loadstart", function() { + found_loadstart = true; + }); + v.addEventListener("progress", function() { + t.step(function() { + assert_true(found_loadstart); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - loadstart, then progress"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_pause.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_pause.html new file mode 100644 index 000000000..1f7904c3b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_pause.html @@ -0,0 +1,48 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - pause</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("calling pause() on autoplay audio should trigger pause event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("pause", function() { + t.step(function() { + assert_true(true); + }); + t.done(); + }, false); + a.addEventListener("play", function() { + a.pause(); // pause right after play + }); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - pause"); + +test(function() { + var t = async_test("calling pause() on autoplay video should trigger pause event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("pause", function() { + t.step(function() { + assert_true(true); + }); + t.done(); + }, false); + v.addEventListener("play", function() { + v.pause(); // pause right after play + }); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - pause"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html new file mode 100644 index 000000000..554823483 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html @@ -0,0 +1,40 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - pause</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("calling play() then pause() on non-autoplay audio should trigger pause event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("pause", function() { + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + a.play(); + a.pause(); +}, "audio events - pause"); + +test(function() { + var t = async_test("calling play() then pause() on non-autoplay video should trigger pause event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("pause", function() { + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + v.play(); + v.pause(); +}, "video events - pause"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_play.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_play.html new file mode 100644 index 000000000..82b2ca407 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_play.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - play</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger play event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("play", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - play"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger play event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("play", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - play"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_play_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_play_noautoplay.html new file mode 100644 index 000000000..67285a95a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_play_noautoplay.html @@ -0,0 +1,40 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - play</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("calling play() on audio should trigger play event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("play", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + a.play(); +}, "audio events - play"); + +test(function() { + var t = async_test("calling play() on video should trigger play event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("play", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + v.play(); +}, "video events - play"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_playing.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_playing.html new file mode 100644 index 000000000..3741a1c98 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_playing.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - playing</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger playing event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("playing", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - playing"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger playing event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("playing", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - playing"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_playing_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_playing_noautoplay.html new file mode 100644 index 000000000..f750085ed --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_playing_noautoplay.html @@ -0,0 +1,40 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - playing</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("calling play() on audio should trigger playing event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("playing", function() { + t.done(); + a.pause(); + }); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + a.play(); +}, "audio events - playing"); + +test(function() { + var t = async_test("calling play() on video should trigger playing event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("playing", function() { + t.done(); + v.pause(); + }); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + v.play(); +}, "video events - playing"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_progress.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_progress.html new file mode 100644 index 000000000..269f824f7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_progress.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - progress</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on autoplay audio should trigger progress event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("progress", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - progress"); + +test(function() { + var t = async_test("setting src attribute on autoplay video should trigger progress event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("progress", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - progress"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_progress_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_progress_noautoplay.html new file mode 100644 index 000000000..c594f3036 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_progress_noautoplay.html @@ -0,0 +1,36 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - progress</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("setting src attribute on non-autoplay audio should trigger progress event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("progress", function() { + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - progress"); + +test(function() { + var t = async_test("setting src attribute on non-autoplay video should trigger progress event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("progress", function() { + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - progress"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_timeupdate.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_timeupdate.html new file mode 100644 index 000000000..cc0a17fe2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_timeupdate.html @@ -0,0 +1,34 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - timeupdate</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +var ta = async_test("setting src attribute on a sufficiently long autoplay audio should trigger timeupdate event", {timeout:5000}); +var a = document.getElementById("a"); +a.addEventListener("timeupdate", function() { + ta.done(); + a.pause(); +}, false); +a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + +var tv = async_test("setting src attribute on a sufficiently long autoplay video should trigger timeupdate event", {timeout:5000}); +var v = document.getElementById("v"); +v.addEventListener("timeupdate", function() { + tv.done(); + v.pause(); +}, false); +v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_timeupdate_noautoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_timeupdate_noautoplay.html new file mode 100644 index 000000000..feb4b8568 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_timeupdate_noautoplay.html @@ -0,0 +1,40 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - timeupdate</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("calling play() on a sufficiently long audio should trigger timeupdate event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("timeupdate", function() { + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + a.play(); +}, "audio events - timeupdate"); + +test(function() { + var t = async_test("calling play() on a sufficiently long video should trigger timeupdate event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("timeupdate", function() { + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + v.play(); +}, "video events - timeupdate"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_volumechange.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_volumechange.html new file mode 100644 index 000000000..3481947e8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/event_volumechange.html @@ -0,0 +1,72 @@ +<!doctype html> +<title>volumechange event</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +function volumechange_test(tagName) { + async_test(function(t) { + var e = document.createElement(tagName); + assert_equals(e.volume, 1); + e.volume = 0.5; + assert_equals(e.volume, 0.5); + e.onvolumechange = t.step_func(function() { + assert_equals(e.volume, 0.5); + e.volume = 1; + assert_equals(e.volume, 1); + e.onvolumechange = t.step_func(function() { + assert_equals(e.volume, 1); + t.done(); + }); + }); + }, "setting " + tagName + ".volume fires volumechange"); + + async_test(function(t) { + var e = document.createElement(tagName); + assert_false(e.muted); + e.muted = true; + assert_true(e.muted); + e.onvolumechange = t.step_func(function() { + assert_true(e.muted); + e.muted = false; + assert_false(e.muted); + e.onvolumechange = t.step_func(function() { + assert_false(e.muted); + t.done(); + }); + }); + }, "setting " + tagName + ".muted fires volumechange"); + + async_test(function(t) { + var e = document.createElement(tagName); + e.volume = e.volume; + e.muted = e.muted; + e.onvolumechange = t.step_func(function() { + assert_unreached(); + }); + var e2 = document.createElement(tagName); + e2.muted = !e2.muted; + e2.onvolumechange = t.step_func(function() { + t.done(); + }); + }, "setting " + tagName + ".volume/muted to the same value does not fire volumechange"); + + async_test(function(t) { + var e = document.createElement(tagName); + e.muted = !e.muted; + e.volume = 1 - e.volume; + e.muted = !e.muted; + e.volume = 1 - e.volume; + var volumechange_count = 0; + e.onvolumechange = t.step_func(function() { + volumechange_count++; + if (volumechange_count == 4) { + t.done(); + } + }); + }, "setting " + tagName + ".volume/muted repeatedly fires volumechange repeatedly"); +} + +volumechange_test("audio"); +volumechange_test("video"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/historical.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/historical.html new file mode 100644 index 000000000..451923408 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/historical.html @@ -0,0 +1,53 @@ +<!doctype html> +<title>Historical media element features should not be supported</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +function t(property, tagName) { + var tagNames = tagName ? [tagName] : ['audio', 'video']; + tagNames.forEach(function(tagName) { + test(function() { + assert_false(property in document.createElement(tagName)); + }, tagName + '.' + property + ' should not be supported'); + }); +} + +t('bufferingRate'); // added in r678, removed in r2872. +t('start'); // added in r692, removed in r2401. +t('end'); // added in r692, removed in r2401. +t('loopStart'); // added in r692, removed in r2401. +t('loopEnd'); // added in r692, removed in r2401. +t('loopCount'); // added in r692, replaced with playCount in r1105. +t('currentLoop'); // added in r692, removed in r2401. +t('addCuePoint'); // added in r721, replaced with addCueRange in r1106. +t('removeCuePoint'); // added in r721, replaced with removeCueRanges in r1106. +t('playCount'); // added in r1105, removed in r2401. +t('addCueRange'); // added in r1106, removed in r5070. +t('removeCueRanges'); // added in r1106, removed in r5070. +t('pixelratio', 'source'); // added in r1629, removed in r2493. +t('bufferedBytes'); // added in r1630, removed in r2405. +t('totalBytes'); // added in r1630, removed in r2405. +t('bufferingThrottled'); // added in r1632, removed in r2872. +t('autobuffer'); // added in r2855, replaced with preload in r4811. +t('startTime'); // added in r3035, replaced with initialTime in r5310. +t('startOffsetTime'); // added in r5310, replaced with startDate in r7045. +t('initialTime'); // added in r5310, removed in r7046. +t('audio', 'video'); // added in r5636, replaced with muted in r5991. +t('startDate'); // added in r7045, replaced with getStartDate() in r8113. + +// TextTrackCue constructor: added in r5723, removed in r7742. +test(function() { + assert_throws(new TypeError(), function() { + new TextTrackCue(0, 0, ''); + }); +}, 'TextTrackCue constructor should not be supported'); + +// added in https://github.com/whatwg/html/commit/66c5b32240c202c74f475872e7ea2cd163777b4a +// removed in https://github.com/whatwg/html/commit/634698e70ea4586d58c989fa7d2cbfcad20d33e6 +t('mediaGroup'); +t('controller'); +test(function() { + assert_false('MediaController' in window); +}, 'MediaController constructor should not be supported'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLMediaElement/addTextTrack.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLMediaElement/addTextTrack.html new file mode 100644 index 000000000..2a76b0a66 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLMediaElement/addTextTrack.html @@ -0,0 +1,116 @@ +<!doctype html> +<title>HTMLMediaElement.addTextTrack</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +var video = document.createElement('video'); +test(function(){ + assert_throws(new TypeError(), function(){ + video.addTextTrack('foo'); + }); + assert_throws(new TypeError(), function(){ + video.addTextTrack(undefined); + }); + assert_throws(new TypeError(), function(){ + video.addTextTrack(null); + }); +}, document.title + ' bogus first arg'); + +test(function(){ + assert_throws(new TypeError(), function(){ + video.addTextTrack('SUBTITLES'); + }); +}, document.title + ' uppercase first arg'); + +test(function(){ + var t = video.addTextTrack('subtitles'); + assert_equals(t.kind, 'subtitles'); + assert_equals(t.label, ''); + assert_equals(t.language, ''); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' subtitles first arg'); + +test(function(){ + var t = video.addTextTrack('captions'); + assert_equals(t.kind, 'captions'); + assert_equals(t.label, ''); + assert_equals(t.language, ''); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' captions first arg'); + +test(function(){ + var t = video.addTextTrack('descriptions'); + assert_equals(t.kind, 'descriptions'); + assert_equals(t.label, ''); + assert_equals(t.language, ''); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' descriptions first arg'); + +test(function(){ + var t = video.addTextTrack('chapters'); + assert_equals(t.kind, 'chapters'); + assert_equals(t.label, ''); + assert_equals(t.language, ''); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' chapters first arg'); + +test(function(){ + var t = video.addTextTrack('metadata'); + assert_equals(t.kind, 'metadata'); + assert_equals(t.label, ''); + assert_equals(t.language, ''); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' metadata first arg'); + +test(function(){ + var t = video.addTextTrack('subtitles', undefined, undefined); + assert_equals(t.kind, 'subtitles'); + assert_equals(t.label, ''); + assert_equals(t.language, ''); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' undefined second and third arg'); + +test(function(){ + var t = video.addTextTrack('subtitles', null, null); + assert_equals(t.kind, 'subtitles'); + assert_equals(t.label, 'null'); + assert_equals(t.language, 'null'); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' null second and third arg'); + +test(function(){ + var t = video.addTextTrack('subtitles', 'foo', 'bar'); + assert_equals(t.kind, 'subtitles'); + assert_equals(t.label, 'foo'); + assert_equals(t.language, 'bar'); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' foo and bar second and third arg'); + +test(function(){ + var t = video.addTextTrack('subtitles', 'foo'); + assert_equals(t.kind, 'subtitles'); + assert_equals(t.label, 'foo'); + assert_equals(t.language, ''); + assert_equals(t.mode, 'hidden'); + assert_true(t.cues instanceof TextTrackCueList); + assert_equals(t.cues.length, 0); +}, document.title + ' foo second arg, third arg omitted'); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLMediaElement/textTracks.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLMediaElement/textTracks.html new file mode 100644 index 000000000..0f183b7e1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLMediaElement/textTracks.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>HTMLMediaElement.textTracks</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +var video = document.createElement('video'); +test(function(){ + assert_equals(video.textTracks, video.textTracks); + assert_equals(video.textTracks.length, 0); +}); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/default.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/default.html new file mode 100644 index 000000000..05fd0f7f7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/default.html @@ -0,0 +1,55 @@ +<!doctype html> +<title>HTMLTrackElement.default</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track['default'], false); + assert_equals(track.getAttribute('default'), null); +}, document.title + ' missing value'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('default', ''); + assert_equals(track['default'], true); + assert_equals(track.getAttribute('default'), ''); +}, document.title + ' empty string content attribute'); + +test(function(){ + var track = document.createElement('track'); + track['default'] = ''; + assert_equals(track['default'], false); + assert_equals(track.getAttribute('default'), null); +}, document.title + ' empty string IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('default', 'foo'); + assert_equals(track['default'], true); + assert_equals(track.getAttribute('default'), 'foo'); +}, document.title + ' foo in content attribute'); + +test(function(){ + var track = document.createElement('track'); + track['default'] = 'foo'; + assert_equals(track['default'], true); + assert_equals(track.getAttribute('default'), ''); +}, document.title + ' foo in IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track['default'] = true; + assert_equals(track['default'], true); + assert_equals(track.getAttribute('default'), ''); +}, document.title + ' true in IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('default', ''); + track['default'] = false; + assert_equals(track['default'], false); + assert_equals(track.getAttribute('default'), null); +}, document.title + ' false in IDL attribute'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/kind.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/kind.html new file mode 100644 index 000000000..78c3bff51 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/kind.html @@ -0,0 +1,146 @@ +<!doctype html> +<title>HTMLTrackElement.kind</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track.kind, 'subtitles'); + assert_equals(track.getAttribute('kind'), null); +}, document.title + ' missing value'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'invalid'); + assert_equals(track.kind, 'metadata'); + assert_equals(track.getAttribute('kind'), 'invalid'); +}, document.title + ' invalid value in content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'CAPTIONS'); + assert_equals(track.kind, 'captions'); + assert_equals(track.getAttribute('kind'), 'CAPTIONS'); +}, document.title + ' content attribute uppercase'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'CAPT\u0130ONS'); + assert_equals(track.kind, 'metadata'); + assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS'); +}, document.title + ' content attribute with uppercase turkish I (with dot)'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'capt\u0131ons'); + assert_equals(track.kind, 'metadata'); + assert_equals(track.getAttribute('kind'), 'capt\u0131ons'); +}, document.title + ' content attribute with lowercase turkish i (dotless)'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'subtitles'); + assert_equals(track.kind, 'subtitles'); + assert_equals(track.getAttribute('kind'), 'subtitles'); +}, document.title + ' content attribute "subtitles"'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'captions'); + assert_equals(track.kind, 'captions'); + assert_equals(track.getAttribute('kind'), 'captions'); +}, document.title + ' content attribute "captions"'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'descriptions'); + assert_equals(track.kind, 'descriptions'); + assert_equals(track.getAttribute('kind'), 'descriptions'); +}, document.title + ' content attribute "descriptions"'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'chapters'); + assert_equals(track.kind, 'chapters'); + assert_equals(track.getAttribute('kind'), 'chapters'); +}, document.title + ' content attribute "chapters"'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'metadata'); + assert_equals(track.kind, 'metadata'); + assert_equals(track.getAttribute('kind'), 'metadata'); +}, document.title + ' content attribute "metadata"'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'captions\u0000'); + assert_equals(track.kind, 'metadata'); + assert_equals(track.getAttribute('kind'), 'captions\u0000'); +}, document.title + ' content attribute "captions\\u0000"'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'subtitles'; + assert_equals(track.getAttribute('kind'), 'subtitles'); + assert_equals(track.kind, 'subtitles'); +}, document.title + ' setting IDL attribute to "subtitles"'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'captions'; + assert_equals(track.getAttribute('kind'), 'captions'); + assert_equals(track.kind, 'captions'); +}, document.title + ' setting IDL attribute to "captions"'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'descriptions'; + assert_equals(track.getAttribute('kind'), 'descriptions'); + assert_equals(track.kind, 'descriptions'); +}, document.title + ' setting IDL attribute to "descriptions"'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'chapters'; + assert_equals(track.getAttribute('kind'), 'chapters'); + assert_equals(track.kind, 'chapters'); +}, document.title + ' setting IDL attribute to "chapters"'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'metadata'; + assert_equals(track.getAttribute('kind'), 'metadata'); + assert_equals(track.kind, 'metadata'); +}, document.title + ' setting IDL attribute to "metadata"'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'CAPTIONS'; + assert_equals(track.getAttribute('kind'), 'CAPTIONS'); + assert_equals(track.kind, 'captions'); +}, document.title + ' setting IDL attribute to "CAPTIONS"'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'CAPT\u0130ONS'; + assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS'); + assert_equals(track.kind, 'metadata'); +}, document.title + ' setting IDL attribute with uppercase turkish I (with dot)'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'capt\u0131ons'; + assert_equals(track.getAttribute('kind'), 'capt\u0131ons'); + assert_equals(track.kind, 'metadata'); +}, document.title + ' setting IDL attribute with lowercase turkish I (dotless)'); + +test(function(){ + var track = document.createElement('track'); + track.kind = 'captions\u0000'; + assert_equals(track.getAttribute('kind'), 'captions\u0000'); + assert_equals(track.kind, 'metadata'); +}, document.title + ' setting IDL attribute with \\u0000'); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/label.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/label.html new file mode 100644 index 000000000..b2360315c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/label.html @@ -0,0 +1,83 @@ +<!doctype html> +<title>HTMLTrackElement.label</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track.label, ''); + assert_equals(track.getAttribute('label'), null); +}, document.title + ' missing value'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('label', ''); + assert_equals(track.label, ''); + assert_equals(track.getAttribute('label'), ''); +}, document.title + ' empty string content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.label = ''; + assert_equals(track.label, ''); + assert_equals(track.getAttribute('label'), ''); +}, document.title + ' empty string IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('label', 'foo'); + assert_equals(track.label, 'foo'); + assert_equals(track.getAttribute('label'), 'foo'); +}, document.title + ' lowercase content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('label', 'FOO'); + assert_equals(track.label, 'FOO'); + assert_equals(track.getAttribute('label'), 'FOO'); +}, document.title + ' uppercase content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('label', '\u0000'); + assert_equals(track.label, '\u0000'); + assert_equals(track.getAttribute('label'), '\u0000'); +}, document.title + '\\u0000 in content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.label = 'foo'; + assert_equals(track.label, 'foo'); + assert_equals(track.getAttribute('label'), 'foo'); +}, document.title + ' lowercase IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.label = 'FOO'; + assert_equals(track.label, 'FOO'); + assert_equals(track.getAttribute('label'), 'FOO'); +}, document.title + ' uppercase IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('label', ' foo \n'); + assert_equals(track.label, ' foo \n'); + assert_equals(track.getAttribute('label'), ' foo \n'); +}, document.title + ' whitespace in content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.label = ' foo \n'; + assert_equals(track.label, ' foo \n'); + assert_equals(track.getAttribute('label'), ' foo \n'); +}, document.title + ' whitespace in IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.label = '\u0000'; + assert_equals(track.label, '\u0000'); + assert_equals(track.getAttribute('label'), '\u0000'); +}, document.title + ' \\u0000 in IDL attribute'); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/readyState.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/readyState.html new file mode 100644 index 000000000..e18f21934 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/readyState.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>HTMLTrackElement.readyState</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track.readyState, 0); +}, document.title + ' default value'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/src.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/src.html new file mode 100644 index 000000000..4089913cb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/src.html @@ -0,0 +1,43 @@ +<!doctype html> +<title>HTMLTrackElement.src</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track.src, ''); + assert_equals(track.getAttribute('src'), null); +}, document.title + ' missing value'); + +function resolve(url) { + var link = document.createElement('a'); + link.setAttribute('href', url); + return link.href; +} + +var tests = [ + {input:'', expectedIDL:resolve(''), desc:'empty string'}, + {input:'http://foo bar', expectedIDL:'http://foo bar', desc:'unresolvable value'}, + {input:'test', expectedIDL:resolve('test'), desc:'resolvable value'}, + // Leading and trailing C0 controls and space is stripped per url spec. + {input:'\u0000', expectedIDL:resolve(''), desc:'\\u0000'}, + {input:'foo\u0000bar', expectedIDL:resolve('foo%00bar'), desc:'foo\\u0000bar'}, +]; + +tests.forEach(function(t) { + test(function(){ + var track = document.createElement('track'); + track.setAttribute('src', t.input); + assert_equals(track.src, t.expectedIDL); + assert_equals(track.getAttribute('src'), t.input); + }, [document.title, t.desc, 'in content attribute'].join(' ')); + + test(function(){ + var track = document.createElement('track'); + track.src = t.input; + assert_equals(track.src, t.expectedIDL); + assert_equals(track.getAttribute('src'), t.input); + }, [document.title, 'assigning', t.desc, 'to IDL attribute'].join(' ')); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/srclang.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/srclang.html new file mode 100644 index 000000000..b5071e0c3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/srclang.html @@ -0,0 +1,82 @@ +<!doctype html> +<title>HTMLTrackElement.srclang</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track.srclang, ''); + assert_equals(track.getAttribute('srclang'), null); +}, document.title + ' missing value'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('srclang', ''); + assert_equals(track.srclang, ''); + assert_equals(track.getAttribute('srclang'), ''); +}, document.title + ' empty string content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.srclang = ''; + assert_equals(track.srclang, ''); + assert_equals(track.getAttribute('srclang'), ''); +}, document.title + ' empty string IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('srclang', 'foo'); + assert_equals(track.srclang, 'foo'); + assert_equals(track.getAttribute('srclang'), 'foo'); +}, document.title + ' lowercase content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('srclang', 'FOO'); + assert_equals(track.srclang, 'FOO'); + assert_equals(track.getAttribute('srclang'), 'FOO'); +}, document.title + ' uppercase content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('srclang', '\u0000'); + assert_equals(track.srclang, '\u0000'); + assert_equals(track.getAttribute('srclang'), '\u0000'); +}, document.title + ' \\u0000 content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.srclang = 'foo'; + assert_equals(track.srclang, 'foo'); + assert_equals(track.getAttribute('srclang'), 'foo'); +}, document.title + ' lowercase IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.srclang = 'FOO'; + assert_equals(track.srclang, 'FOO'); + assert_equals(track.getAttribute('srclang'), 'FOO'); +}, document.title + ' uppercase IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.setAttribute('srclang', ' foo \n'); + assert_equals(track.srclang, ' foo \n'); + assert_equals(track.getAttribute('srclang'), ' foo \n'); +}, document.title + ' whitespace in content attribute'); + +test(function(){ + var track = document.createElement('track'); + track.srclang = ' foo \n'; + assert_equals(track.srclang, ' foo \n'); + assert_equals(track.getAttribute('srclang'), ' foo \n'); +}, document.title + ' whitespace in IDL attribute'); + +test(function(){ + var track = document.createElement('track'); + track.srclang = '\u0000'; + assert_equals(track.srclang, '\u0000'); + assert_equals(track.getAttribute('srclang'), '\u0000'); +}, document.title + ' \\u0000 in IDL attribute'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/track.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/track.html new file mode 100644 index 000000000..1de0a8804 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/HTMLElement/HTMLTrackElement/track.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>HTMLTrackElement.track</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track.track, track.track, 'same object should be returned'); + assert_true(track.track instanceof TextTrack, 'returned object should be a TextTrack'); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/activeCues.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/activeCues.html new file mode 100644 index 000000000..689ec12be --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/activeCues.html @@ -0,0 +1,104 @@ +<!doctype html> +<title>TextTrack.activeCues</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=/common/media.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + window.track = document.createElement('track'); + track['default'] = true; + video.appendChild(track); + window.t2 = track.track; + t2.mode = 'showing'; + window.t1_cues = t1.activeCues; + window.t2_cues = t2.activeCues; + document.body.appendChild(video); + if (!t1) + throw new Error('t1 was undefined') +}, {timeout:25000}); +function smoke_test() { + assert_true('HTMLTrackElement' in window, 'track not supported'); +} + +test(function(){ + smoke_test(); + assert_equals(t1.activeCues, t1_cues, 't1.activeCues should return same object'); + assert_equals(t2.activeCues, t2_cues, 't2.activeCues should return same object'); + assert_not_equals(t1.activeCues, t2.activeCues, 't1.activeCues and t2.activeCues should be different objects'); + assert_not_equals(t1.activeCues, null, 't1.activeCues should not be null'); + assert_not_equals(t2.activeCues, null, 't2.activeCues should not be null'); + assert_equals(t1.activeCues.length, 0, 't1.activeCues should have length 0'); + assert_equals(t2.activeCues.length, 0, 't2.activeCues should have length 0'); +}, document.title+', empty list'); +test(function(){ + smoke_test(); + var c = new VTTCue(0, 1, "text"); + t1.addCue(c); + assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return same object"); + assert_equals(t1.activeCues.length, 0, "t1.activeCues.length"); + var c2 = new VTTCue(1, 2, "text2"); + t1.addCue(c2); + assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after adding a second cue"); + assert_equals(t1.activeCues.length, 0, "t1.activeCues.length after adding a second cue"); +}, document.title+', after addCue()'); +test(function(){ + smoke_test(); + t1.mode = 'showing'; + assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after setting mode to showing"); + t1.mode = 'hidden'; + assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after setting mode to hidden"); + t1.mode = 'disabled'; + assert_equals(t1.activeCues, null, "t1.activeCues should be null when mode is disabled"); + assert_equals(t1_cues.length, 0, "t1_cues should still be intact after setting mode to disabled"); +}, document.title+', different modes'); + +// ok now let's load in a video +var test1 = async_test(document.title+', video loading', {timeout:20000}); +var test2 = async_test(document.title+', video playing', {timeout:20000}); +var test3 = async_test(document.title+', adding cue during playback', {timeout:20000}); +test1.step(smoke_test); +test2.step(smoke_test); +test3.step(smoke_test); +test1.step(function(){ + t1.mode = 'showing'; + video.onloadeddata = test1.step_func(function(e) { + video.onplaying = test2.step_func(function(e) { + try { + assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after playing a video"); + assert_equals(t1.activeCues.length, 1, "t1.activeCues.length after the video has started playing"); + } catch(ex) { + test2.step(function() { throw ex; }); + test3.step(function() { assert_unreached(); }); + return; + } + test3.step(function(){ + var c3 = new VTTCue(0, 2, "text3"); + t1.addCue(c3); + assert_equals(t1.activeCues.length, 1, "t1.activeCues.length after adding a cue in the same script"); + setTimeout(test3.step_func(function(){ + assert_equals(t1.activeCues.length, 2, "t1.activeCues.length after the event loop has spun"); + test3.done(); + }, 0)); + }); + test2.done(); + }); + try { + assert_equals(t1.activeCues, t1_cues, "t1.activeCues should return the same object after loading a video"); + assert_equals(t2.activeCues, t2_cues, "t2.activeCues should return the same object after loading a video"); + assert_equals(t1.activeCues.length, 0, "t1.activeCues.length before the video has started playing"); + assert_equals(t2.activeCues.length, 0, "t1.activeCues.length before the video has started playing"); + } catch(ex) { + test1.step(function() { throw ex; }); + test2.step(function() { assert_unreached(); }); + test3.step(function() { assert_unreached(); }); + return; + } + video.play(); + test1.done(); + }); + video.src = getVideoURI("/media/movie_5"); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/addCue.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/addCue.html new file mode 100644 index 000000000..267941334 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/addCue.html @@ -0,0 +1,68 @@ +<!doctype html> +<title>TextTrack.addCue()</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + document.body.appendChild(video); +}, {timeout:5000}); +test(function() { + var t1 = video.addTextTrack('subtitles'); + var t2 = video.addTextTrack('subtitles'); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + t2.addCue(c1); + assert_equals(c1.track, t2); +}, document.title+', adding a cue to two different tracks'); +test(function() { + var t1 = video.addTextTrack('subtitles'); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + assert_equals(c1.track, t1); + t1.addCue(c1); + assert_equals(c1.track, t1); +}, document.title+', adding a cue to a track twice'); +test(function() { + var t1 = video.addTextTrack('subtitles'); + var t2 = video.addTextTrack('subtitles'); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + assert_equals(c1.track, t1); + t1.removeCue(c1); + assert_equals(c1.track, null); + t2.addCue(c1); + assert_equals(c1.track, t2); +}, document.title+', adding a removed cue to a different track'); +test(function() { + var t1 = video.addTextTrack('subtitles'); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + assert_equals(t1.cues.length, 1, 't1.cues.length after first addition'); + t1.removeCue(c1); + assert_equals(t1.cues.length, 0, 't1.cues.length after removal'); + t1.addCue(c1); + assert_equals(t1.cues.length, 1, 't1.cues.length after second addition'); +}, document.title+', adding an associated but removed cue to the same track'); + +var t = async_test(document.title+', adding a cue associated with a track element to other track'); +t.step(function(){ + var t1 = video.addTextTrack('subtitles'); + var track = document.createElement('track'); + track.onload = t.step_func(function(){ + var cue = track.track.cues[0]; + track.track.removeCue(cue); + t1.addCue(cue); + assert_equals(cue.track, t1); + t.done(); + }); + track.onerror = t.step_func(function() { + assert_unreached('got error event'); + }); + track.src= 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:01.000\ntest\n'); + track.kind = 'subtitles'; + track.track.mode = 'hidden'; + video.appendChild(track); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/constants.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/constants.html new file mode 100644 index 000000000..3c8046cdc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/constants.html @@ -0,0 +1,23 @@ +<!doctype html> +<title>TextTrack constants</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); +}); +test(function(){ + assert_equals(t1.DISABLED, undefined, "t1.DISABLED"); + assert_equals(t1.HIDDEN, undefined, "t1.HIDDEN"); + assert_equals(t1.SHOWING, undefined, "t1.SHOWING"); + assert_equals(TextTrack.prototype.DISABLED, undefined, "TextTrack.prototype.DISABLED"); + assert_equals(TextTrack.prototype.HIDDEN, undefined, "TextTrack.prototype.HIDDEN"); + assert_equals(TextTrack.prototype.SHOWING, undefined, "TextTrack.prototype.SHOWING"); + assert_equals(TextTrack.DISABLED, undefined, "TextTrack.DISABLED"); + assert_equals(TextTrack.HIDDEN, undefined, "TextTrack.HIDDEN"); + assert_equals(TextTrack.SHOWING, undefined, "TextTrack.SHOWING"); +}); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html new file mode 100644 index 000000000..4b7808c96 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html @@ -0,0 +1,100 @@ +<!doctype html> +<title>TextTrack.cues</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var video = document.createElement('video'); + var t1 = video.addTextTrack('subtitles'); + assert_equals(t1.cues, t1.cues, 't1.cues should return same object'); + assert_not_equals(t1.cues, null, 't1.cues should not be null'); + assert_true(t1.cues instanceof TextTrackCueList, 't1.cues instanceof TextTrackCueList'); + assert_equals(t1.cues.length, 0, 't1.cues.length'); +}, document.title+', empty list'); + +function addCue(texttrack, start, end, text, id) { + var c = new VTTCue(start, end, text); + c.id = id; + texttrack.addCue(c); + return c; +} + +test(function(){ + var video = document.createElement('video'); + var t1 = video.addTextTrack('subtitles'); + var t1_cues = t1.cues; + var c = addCue(t1, 0, 1, 'text', 'id'); + assert_equals(t1.cues, t1_cues, "t1.cues should return same object"); + assert_equals(t1.cues.length, 1, "t1.cues.length"); + var c2 = addCue(t1, 1, 2, 'text2', 'id2'); + assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after adding a second cue"); + assert_equals(t1.cues.length, 2, "t1.cues.length after adding a second cue"); + assert_equals(t1.cues[0].id, "id"); + assert_equals(t1.cues[1].id, "id2"); +}, document.title+', after addCue()'); + +test(function(){ + var video = document.createElement('video'); + var t1 = video.addTextTrack('subtitles'); + var t1_cues = t1.cues; + var c = addCue(t1, 0, 1, 'text', 'id'); + var c2 = addCue(t1, 1, 2, 'text2', 'id2'); + t1.mode = 'showing'; + assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'showing'"); + t1.mode = 'hidden'; + assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'hidden'"); + t1.mode = 'disabled'; + assert_equals(t1.cues, null, "t1.cues should be null when mode is 'disabled'"); + assert_equals(t1_cues.length, 2, "t1_cues should still be intact after setting mode to 'disabled'"); + assert_equals(t1_cues[0].id, "id", "t1_cues first cue should still be intact after setting mode to 'disabled'"); + assert_equals(t1_cues[1].id, "id2", "t1_cues second cue should still be intact after setting mode to 'disabled'"); + t1.mode = 'hidden'; + assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'disabled' and then 'hidden'"); + t1.mode = 'disabled'; + assert_equals(t1.cues, null, "t1.cues should be null when mode is set to 'disabled' again"); + assert_equals(t1_cues.length, 2, "t1_cues should still be intact after setting mode to 'disabled' again"); + assert_equals(t1_cues[0].id, "id", "t1_cues first cue should still be intact after setting mode to 'disabled' again"); + assert_equals(t1_cues[1].id, "id2", "t1_cues second cue should still be intact after setting mode to 'disabled' again"); + t1.mode = 'showing'; + assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'disabled' and then 'showing'"); +}, document.title+', different modes'); + +test(function(){ + var video = document.createElement('video'); + var t1 = video.addTextTrack('subtitles'); + var t1_cues = t1.cues; + var c = addCue(t1, 0, 1, 'text', 'id'); + var c2 = addCue(t1, 1, 2, 'text2', 'id2'); + t1.mode = 'showing'; + t1.cues[1].startTime = 0; // this should change the text track cue order + assert_equals(t1.cues[0].id, 'id2'); + assert_equals(t1.cues[1].id, 'id'); + t1.cues[0].startTime = 0.5; // this should change it back + assert_equals(t1.cues[0].id, 'id'); + assert_equals(t1.cues[1].id, 'id2'); +}, document.title+', changing order'); + +async_test(function(){ + var video = document.createElement('video'); + var t1 = video.addTextTrack('subtitles'); + var t1_cues = t1.cues; + t1.mode = 'hidden'; + var track = document.createElement('track'); + track['default'] = true; + video.appendChild(track); // queues a task to "honor user preferences...", media element event task source + var t2 = track.track; + assert_equals(t2.cues, null, 't2.cues should be null'); + // We need to wait until the "honor user preferences..." steps have run so we invoke play() + // which queues an event with the same task source. + video.onplay = this.step_func(function(){ + assert_equals(t2.cues, t2.cues, 't2.cues should return same object'); + assert_not_equals(t1.cues, t2.cues, 't1.cues and t2.cues should be different objects'); + assert_not_equals(t2.cues, null, 't2.cues should not be null'); + assert_true(t2.cues instanceof TextTrackCueList, 't2.cues instanceof TextTrackCueList'); + assert_equals(t2.cues.length, 0, 't2.cues should have length 0'); + this.done(); + }); + video.play(); // queues a task to fire 'play', media element event task source +}, document.title+', default attribute'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/kind.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/kind.html new file mode 100644 index 000000000..d5dbc8342 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/kind.html @@ -0,0 +1,31 @@ +<!doctype html> +<title>TextTrack.kind</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var video = document.createElement('video'); + var t1 = video.addTextTrack('subtitles'); + var t2 = video.addTextTrack('captions'); + var t3 = video.addTextTrack('descriptions'); + var t4 = video.addTextTrack('chapters'); + var t5 = video.addTextTrack('metadata'); + assert_equals(t1.kind, 'subtitles'); + assert_equals(t2.kind, 'captions'); + assert_equals(t3.kind, 'descriptions'); + assert_equals(t4.kind, 'chapters'); + assert_equals(t5.kind, 'metadata'); +}, document.title+', addTextTrack'); +test(function(){ + var track = document.createElement('track'); + track.setAttribute('kind', 'CAPTIONS'); + var t = track.track; + assert_equals(t.kind, 'captions'); +}, document.title+', track element'); +test(function(){ + var track = document.createElement('track'); + track.kind = 'captions\u0000'; + assert_equals(track.track.kind, 'metadata'); +}, document.title+', \\u0000'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/label.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/label.html new file mode 100644 index 000000000..c60e85c21 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/label.html @@ -0,0 +1,29 @@ +<!doctype html> +<title>TextTrack.label</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles', 'foo'); + window.track = document.createElement('track'); + track.setAttribute('label', 'bar'); + video.appendChild(track); + window.t2 = track.track; +}); +test(function(){ + assert_equals(t1.label, 'foo'); + assert_equals(t2.label, 'bar'); + track.label = 'baz'; + assert_equals(t2.label, 'baz'); + track.removeAttribute('label'); + assert_equals(t2.label, ''); +}); +test(function(){ + track.label = '\u0000a'; + assert_equals(t2.label, '\u0000a'); + track.setAttribute('label', '\u0000b', 'IDL attribute'); + assert_equals(t2.label, '\u0000b', 'content attribute'); +}, document.title+', \\u0000'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/language.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/language.html new file mode 100644 index 000000000..eda3653de --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/language.html @@ -0,0 +1,29 @@ +<!doctype html> +<title>TextTrack.language</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles', 'foo', 'foo'); + window.track = document.createElement('track'); + track.setAttribute('srclang', 'bar'); + video.appendChild(track); + window.t2 = track.track; +}); +test(function(){ + assert_equals(t1.language, 'foo'); + assert_equals(t2.language, 'bar'); + track.srclang = 'baz'; + assert_equals(t2.language, 'baz'); + track.removeAttribute('srclang'); + assert_equals(t2.language, ''); +}); +test(function(){ + track.srclang = '\u0000a'; + assert_equals(t2.language, '\u0000a', 'IDL attribute'); + track.setAttribute('srclang', '\u0000b'); + assert_equals(t2.language, '\u0000b', 'content attribute'); +}, document.title+', \\u0000'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/mode.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/mode.html new file mode 100644 index 000000000..9f9415670 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/mode.html @@ -0,0 +1,55 @@ +<!doctype html> +<title>TextTrack.mode</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var track = document.createElement('track'); + assert_equals(track.track.mode, 'disabled', 'initial'); + track.track.mode = 1; + assert_equals(track.track.mode, 'disabled', '1'); + track.track.mode = ''; + assert_equals(track.track.mode, 'disabled', '""'); + track.track.mode = null; + assert_equals(track.track.mode, 'disabled', 'null'); + track.track.mode = undefined; + assert_equals(track.track.mode, 'disabled', 'undefined'); + track.track.mode = 'showing'; + assert_equals(track.track.mode, 'showing', 'showing (correct value)'); + track.track.mode = 'DISABLED'; + assert_equals(track.track.mode, 'showing', '"DISABLED"'); + track.track.mode = 'd\u0130sabled'; // dotted uppercase i + assert_equals(track.track.mode, 'showing', '"d\u0130sabled" (dotted uppercase i)'); + track.track.mode = 'd\u0131sabled'; // dotless lowercase i + assert_equals(track.track.mode, 'showing', '"d\u0131sabled" (dotless lowercase i)'); + track.track.mode = 'disabled '; + assert_equals(track.track.mode, 'showing', '"disabled "'); + track.track.mode = ' disabled'; + assert_equals(track.track.mode, 'showing', '" disabled"'); + track.track.mode = {}; + assert_equals(track.track.mode, 'showing', '{}'); + track.track.mode = 'HIDDEN'; + assert_equals(track.track.mode, 'showing', '"HIDDEN"'); + track.track.mode = 'h\u0130dden'; // dotted uppercase i + assert_equals(track.track.mode, 'showing', '"h\u0130dden" (dotted uppercase i)'); + track.track.mode = 'h\u0131dden'; // dotless lowercase i + assert_equals(track.track.mode, 'showing', '"h\u0131dden" (dotless lowercase i)'); +}, document.title+', wrong value'); +test(function() { + var track = document.createElement('track'); + assert_equals(track.track.mode, 'disabled', 'initial'); + track.track.mode = 'disabled'; // no-op + assert_equals(track.track.mode, 'disabled', 'disabled (1)'); + track.track.mode = 'hidden'; + assert_equals(track.track.mode, 'hidden', 'hidden (1)'); + track.track.mode = 'hidden'; // no-op + assert_equals(track.track.mode, 'hidden', 'hidden (2)'); + track.track.mode = 'showing'; + assert_equals(track.track.mode, 'showing', 'showing (1)'); + track.track.mode = 'showing'; // no-op + assert_equals(track.track.mode, 'showing', 'showing (2)'); + track.track.mode = {toString:function() { return 'disabled'; }}; + assert_equals(track.track.mode, 'disabled', '{toString:...}'); +}, document.title+', correct value'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/oncuechange.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/oncuechange.html new file mode 100644 index 000000000..16c76f948 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/oncuechange.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>TextTrack.oncuechange</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + window.ev = new Event('cuechange'); + window.ran = false; + window.cb = function() { ran = true; }; +}); +test(function(){ + assert_equals(t1.oncuechange, null); + t1.oncuechange = cb; + t1.dispatchEvent(ev); + assert_true(ran); + t1.oncuechange = null; + ran = false; + t1.dispatchEvent(ev); + assert_false(ran); +}); +test(function(){ + t1.addEventListener('cuechange', cb, false); + t1.dispatchEvent(ev); + assert_true(ran); + t1.removeEventListener('cuechange', cb, false); + ran = false; + t1.dispatchEvent(ev); + assert_false(ran); +}, 'TextTrack.addEventListener/removeEventListener'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/removeCue.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/removeCue.html new file mode 100644 index 000000000..3623f44bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/removeCue.html @@ -0,0 +1,50 @@ +<!doctype html> +<title>TextTrack.removeCue()</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + document.body.appendChild(video); +}, {timeout:5000}); +test(function() { + var t1 = video.addTextTrack('subtitles'); + var t2 = video.addTextTrack('subtitles'); + var c1 = new VTTCue(0, 1, 'text1'); + assert_throws("NOT_FOUND_ERR", function() { + t1.removeCue(c1); + }, 'standalone'); + t1.addCue(c1); + assert_throws("NOT_FOUND_ERR", function() { + t2.removeCue(c1); + }, 'listed in t1, remove from t2'); + t1.removeCue(c1); + assert_throws("NOT_FOUND_ERR", function() { + t1.removeCue(c1); + }, 'standalone, remove from t1'); + assert_throws("NOT_FOUND_ERR", function() { + t2.removeCue(c1); + }, 'standalone, remove from t2'); +}, document.title+', two elementless tracks'); +var t = async_test(document.title+', cue from track element'); +t.step(function(){ + var t1 = video.addTextTrack('subtitles'); + var track = document.createElement('track'); + track.onload = t.step_func(function(){ + var cue = track.track.cues[0]; + assert_throws('NOT_FOUND_ERR', function() { t1.removeCue(cue); }, 'listed in track.track, remove from t1'); + track.track.removeCue(cue); + assert_throws('NOT_FOUND_ERR', function() { track.track.removeCue(cue); }, 'standalone, remove from track.track'); + assert_throws('NOT_FOUND_ERR', function() { t1.removeCue(cue); }, 'standalone, remove from t1'); + t.done(); + }); + track.onerror = t.step_func(function() { + assert_unreached('got error event'); + }); + track.src= 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:01.000\ntest\n'); + track.kind = 'subtitles'; + track.track.mode = 'hidden'; + video.appendChild(track); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/endTime.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/endTime.html new file mode 100644 index 000000000..b99a12e05 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/endTime.html @@ -0,0 +1,39 @@ +<!doctype html> +<title>TextTrackCue.endTime</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + document.body.appendChild(video); +}); +test(function(){ + var c1 = new VTTCue(-2, -1, 'text1'); + assert_equals(c1.endTime, -1); + c1.endTime = c1.endTime; + assert_equals(c1.endTime, -1); + assert_throws(new TypeError(), function(){ c1.endTime = NaN; }); + assert_throws(new TypeError(), function(){ c1.endTime = +Infinity; }); + assert_throws(new TypeError(), function(){ c1.endTime = -Infinity; }); +}, document.title+', script-created cue'); + +var t_parsed = async_test(document.title+', parsed cue'); +t_parsed.step(function(){ + var t = document.createElement('track'); + t.onload = this.step_func(function(){ + var c = t.track.cues; + assert_equals(c[0].endTime, 0.001); + assert_equals(c[1].endTime, 3600.001); + this.done(); + }); + t.onerror = this.step_func(function() { + assert_unreached('got error event'); + }); + t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'+ + '\n\nfoobar\n01:00:00.000 --> 01:00:00.001\ntest'); + t.track.mode = 'showing'; + video.appendChild(t); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/id.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/id.html new file mode 100644 index 000000000..a88f94766 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/id.html @@ -0,0 +1,39 @@ +<!doctype html> +<title>TextTrackCue.id</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + document.body.appendChild(video); +}); +test(function(){ + var c1 = new VTTCue(0, 1, 'text1'); + c1.id = 'id1\r\n\u0000'; + assert_equals(c1.id, 'id1\r\n\u0000'); + c1.id = c1.id; + assert_equals(c1.id, 'id1\r\n\u0000'); + c1.id = null; + assert_equals(c1.id, 'null'); +}, document.title+', script-created cue'); + +var t_parsed = async_test(document.title+', parsed cue'); +t_parsed.step(function(){ + var t = document.createElement('track'); + t.onload = this.step_func(function(){ + var c = t.track.cues; + assert_equals(c[0].id, ''); + assert_equals(c[1].id, 'foobar'); + this.done(); + }); + t.onerror = this.step_func(function() { + assert_unreached('got error event'); + }); + t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'+ + '\n\nfoobar\n00:00:00.000 --> 00:00:00.001\ntest'); + t.track.mode = 'showing'; + video.appendChild(t); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onenter.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onenter.html new file mode 100644 index 000000000..17deed053 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onenter.html @@ -0,0 +1,36 @@ +<!doctype html> +<title>TextTrackCue.onenter</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.c1 = new VTTCue(0, 1, 'text1'); + window.ev = new Event('enter'); + window.ran = false; + window.cb = function() { ran = true; }; +}); +test(function(){ + assert_equals(c1.onenter, null, 'initial value'); + c1.onenter = undefined; + assert_equals(c1.onenter, null, 'assigning undefined'); + c1.onenter = cb; + assert_equals(c1.onenter, cb, 'assigning onenter'); + c1.dispatchEvent(ev); + assert_true(ran, 'dispatching event'); + c1.onenter = null; + assert_equals(c1.onenter, null, 'assigning null'); + ran = false; + c1.dispatchEvent(ev); + assert_false(ran, 'dispatching event after nulling onenter'); +}); +test(function(){ + c1.addEventListener('enter', cb, false); + c1.dispatchEvent(ev); + assert_true(ran); + c1.removeEventListener('enter', cb, false); + ran = false; + c1.dispatchEvent(ev); + assert_false(ran); +}, 'TextTrackCue.addEventListener/removeEventListener'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onexit.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onexit.html new file mode 100644 index 000000000..815377e4d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onexit.html @@ -0,0 +1,36 @@ +<!doctype html> +<title>TextTrackCue.onexit</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.c1 = new VTTCue(0, 1, 'text1'); + window.ev = new Event('exit'); + window.ran = false; + window.cb = function() { ran = true; }; +}); +test(function(){ + assert_equals(c1.onexit, null, 'initial value'); + c1.onexit = undefined; + assert_equals(c1.onexit, null, 'assigning undefined'); + c1.onexit = cb; + assert_equals(c1.onexit, cb, 'assigning onexit'); + c1.dispatchEvent(ev); + assert_true(ran, 'dispatching event'); + c1.onexit = null; + assert_equals(c1.onexit, null, 'assigning null'); + ran = false; + c1.dispatchEvent(ev); + assert_false(ran, 'dispatching event after nulling onexit'); +}); +test(function(){ + c1.addEventListener('exit', cb, false); + c1.dispatchEvent(ev); + assert_true(ran); + c1.removeEventListener('exit', cb, false); + ran = false; + c1.dispatchEvent(ev); + assert_false(ran); +}, 'TextTrackCue.addEventListener/removeEventListener'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/pauseOnExit.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/pauseOnExit.html new file mode 100644 index 000000000..31ea4c63b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/pauseOnExit.html @@ -0,0 +1,40 @@ +<!doctype html> +<title>TextTrackCue.pauseOnExit</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + document.body.appendChild(video); +}); +test(function(){ + var c1 = new VTTCue(0, 1, 'text1'); + assert_equals(c1.pauseOnExit, false); + c1.pauseOnExit = null; + assert_equals(c1.pauseOnExit, false); + c1.pauseOnExit = 'foo'; + assert_equals(c1.pauseOnExit, true); +}, document.title+', script-created cue'); + +var t_parsed = async_test(document.title+', parsed cue'); +t_parsed.step(function(){ + var t = document.createElement('track'); + t.onload = this.step_func(function(){ + var c1 = t.track.cues[0]; + assert_equals(c1.pauseOnExit, false); + c1.pauseOnExit = null; + assert_equals(c1.pauseOnExit, false); + c1.pauseOnExit = 'foo'; + assert_equals(c1.pauseOnExit, true); + this.done(); + }); + t.onerror = this.step_func(function() { + assert_unreached('got error event'); + }); + t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'); + t.track.mode = 'showing'; + video.appendChild(t); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/startTime.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/startTime.html new file mode 100644 index 000000000..232a7f23b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/startTime.html @@ -0,0 +1,39 @@ +<!doctype html> +<title>TextTrackCue.startTime</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + document.body.appendChild(video); +}); +test(function(){ + var c1 = new VTTCue(-1, 1, 'text1'); + assert_equals(c1.startTime, -1); + c1.startTime = c1.startTime; + assert_equals(c1.startTime, -1); + assert_throws(new TypeError(), function(){ c1.startTime = NaN; }); + assert_throws(new TypeError(), function(){ c1.startTime = +Infinity; }); + assert_throws(new TypeError(), function(){ c1.startTime = -Infinity; }); +}, document.title+', script-created cue'); + +var t_parsed = async_test(document.title+', parsed cue'); +t_parsed.step(function(){ + var t = document.createElement('track'); + t.onload = this.step_func(function(){ + var c = t.track.cues; + assert_equals(c[0].startTime, 0); + assert_equals(c[1].startTime, 3600); + this.done(); + }); + t.onerror = this.step_func(function() { + assert_unreached('got error event'); + }); + t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'+ + '\n\nfoobar\n01:00:00.000 --> 01:00:00.001\ntest'); + t.track.mode = 'showing'; + video.appendChild(t); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/track.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/track.html new file mode 100644 index 000000000..219e3e703 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/track.html @@ -0,0 +1,38 @@ +<!doctype html> +<title>TextTrackCue.track</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + document.body.appendChild(video); +}); +test(function(){ + var c1 = new VTTCue(0, 1, 'text1'); + assert_equals(c1.track, null); + t1.addCue(c1); + assert_equals(c1.track, t1); + t1.removeCue(c1); + assert_equals(c1.track, null); +}, document.title+', script-created cue'); + +var t_parsed = async_test(document.title+', parsed cue'); +t_parsed.step(function(){ + var t = document.createElement('track'); + t.onload = this.step_func(function(){ + var c = t.track.cues[0]; + assert_equals(c.track, t.track); + t.track.removeCue(c); + assert_equals(c.track, null); + this.done(); + }); + t.onerror = this.step_func(function() { + assert_unreached('got error event'); + }); + t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest'); + t.track.mode = 'showing'; + video.appendChild(t); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/getCueById.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/getCueById.html new file mode 100644 index 000000000..8184189b0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/getCueById.html @@ -0,0 +1,53 @@ +<!doctype html> +<title>TextTrackCueList.getCueById</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var video = document.createElement('video'); + var t = video.addTextTrack('subtitles'); + document.body.appendChild(video); + var cues = t.cues; + var c = new VTTCue(0, 1, 'text1'); + t.addCue(c); + assert_equals(cues.getCueById(""), null, '""'); + assert_equals(cues.getCueById(null), null, 'null'); + assert_equals(cues.getCueById(undefined), null, 'undefined'); +}, document.title+ ', no id'); +test(function(){ + var video = document.createElement('video'); + var t = video.addTextTrack('subtitles'); + document.body.appendChild(video); + var cues = t.cues; + var c = new VTTCue(0, 1, 'text1'); + c.id = 'foo'; + t.addCue(c); + assert_equals(cues.getCueById(""), null, '""'); + assert_equals(cues.getCueById("foo"), c, '"foo"'); + assert_equals(cues.getCueById({toString:function(){return "foo"}}), c, 'object'); +}, document.title+ ', id foo'); +test(function(){ + var video = document.createElement('video'); + var t = video.addTextTrack('subtitles'); + document.body.appendChild(video); + var cues = t.cues; + var c = new VTTCue(0, 1, 'text1'); + c.id = '1'; + t.addCue(c); + assert_equals(cues.getCueById(""), null, '""'); + assert_equals(cues.getCueById("1"), c, '"1"'); + assert_equals(cues.getCueById(1), c, '1'); +}, document.title+ ', no 1'); +test(function(){ + var video = document.createElement('video'); + var t = video.addTextTrack('subtitles'); + document.body.appendChild(video); + var cues = t.cues; + var c = new VTTCue(0, 1, 'text1'); + c.id = 'a\u0000b'; + t.addCue(c); + assert_equals(cues.getCueById("a\u0000b"), c, '"a\\u0000b"'); + assert_equals(cues.getCueById("a"), null, '"a"'); +}, document.title+ ', id a\\u0000b'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/getter.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/getter.html new file mode 100644 index 000000000..d9cd87172 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/getter.html @@ -0,0 +1,49 @@ +<!doctype html> +<title>TextTrackCueList getter</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + document.body.appendChild(video); +}); +test(function(){ + var cues = t1.cues; + assert_equals(cues[0], undefined, 'cues[0] before'); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + assert_equals(cues[0], c1, 'cues[0]'); + assert_equals(cues[1], undefined, 'cues[1]'); + assert_equals(cues[-1], undefined, 'cues[-1]'); + t1.removeCue(c1); + assert_equals(cues[0], undefined, 'cues[0] after'); +}); +test(function(){ + var cues = t1.cues; + assert_equals(cues[0], undefined); + cues[0] = 'foo'; + assert_equals(cues[0], undefined); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + assert_equals(cues[0], c1); + cues[0] = 'foo'; + assert_equals(cues[0], c1); + t1.removeCue(c1); +}, document.title+', no indexed set/create'); +test(function(){ + 'use strict'; + var cues = t1.cues; + assert_equals(cues[0], undefined); + assert_throws(new TypeError(), function() { cues[0] = 'foo'; }); + assert_equals(cues[0], undefined); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + assert_equals(cues[0], c1); + assert_throws(new TypeError(), function() { cues[0] = 'foo'; }); + assert_equals(cues[0], c1); + t1.removeCue(c1); +}, document.title+', no indexed set/create (strict)'); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/length.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/length.html new file mode 100644 index 000000000..91e6e7ff9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCueList/length.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>TextTrackCueList.length</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + window.t1 = video.addTextTrack('subtitles'); + document.body.appendChild(video); +}); +test(function(){ + var cues = t1.cues; + assert_equals(cues.length, 0); + var c1 = new VTTCue(0, 1, 'text1'); + t1.addCue(c1); + assert_equals(cues.length, 1); + t1.removeCue(c1); + assert_equals(cues.length, 0); +}); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/getTrackById.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/getTrackById.html new file mode 100644 index 000000000..b701dd5e7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/getTrackById.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>TextTrackList.getTrackById</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var video = document.createElement('video'); + var track1 = video.addTextTrack('subtitles'); + var track2 = video.addTextTrack('subtitles'); + assert_equals(track1.id, ''); + assert_equals(track2.id, ''); + assert_equals(video.textTracks.getTrackById(''), track1); + assert_equals(video.textTracks.getTrackById('fake-id'), null); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/getter.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/getter.html new file mode 100644 index 000000000..8c5fb3759 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/getter.html @@ -0,0 +1,32 @@ +<!doctype html> +<title>TextTrackList getter</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + video.addTextTrack('subtitles', 'b'); + window.track = document.createElement('track'); + track.label = 'a'; + video.appendChild(track); + video.addTextTrack('subtitles', 'c'); +}); +test(function(){ + assert_equals(video.textTracks[0].label, 'a'); + assert_equals(video.textTracks[1].label, 'b'); + assert_equals(video.textTracks[2].label, 'c'); +}); +test(function(){ + var track_before = video.textTracks[0]; + video.textTracks[0] = 'foo'; + assert_equals(video.textTracks[0], track_before); +}, document.title+', no indexed set/create'); +test(function(){ + 'use strict'; + var track_before = video.textTracks[0]; + assert_throws(new TypeError(), function(){ video.textTracks[0] = 'foo'; }); + assert_equals(video.textTracks[0], track_before); +}, document.title+', no indexed set/create (strict)'); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/length.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/length.html new file mode 100644 index 000000000..7a24130d1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/length.html @@ -0,0 +1,18 @@ +<!doctype html> +<title>TextTrackList.length</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.video = document.createElement('video'); + video.addTextTrack('subtitles'); + window.track = document.createElement('track'); + video.appendChild(track); + video.addTextTrack('subtitles'); +}); +test(function(){ + assert_equals(video.textTracks.length, 3); +}); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/onaddtrack.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/onaddtrack.html new file mode 100644 index 000000000..114ca8904 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/onaddtrack.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>TextTrackList.onaddtrack</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.tracks = document.createElement('video').textTracks; + window.ev = new Event('addtrack'); + window.ran = false; + window.cb = function() { ran = true; }; +}); +test(function(){ + assert_equals(tracks.onaddtrack, null); + tracks.onaddtrack = cb; + assert_equals(tracks.onaddtrack, cb); + tracks.dispatchEvent(ev); + assert_true(ran); + tracks.onaddtrack = null; + ran = false; + tracks.dispatchEvent(ev); + assert_false(ran); +}); +test(function(){ + tracks.addEventListener('addtrack', cb, false); + tracks.dispatchEvent(ev); + assert_true(ran); + tracks.removeEventListener('addtrack', cb, false); + ran = false; + tracks.dispatchEvent(ev); + assert_false(ran); +}, 'TextTrackList.addEventListener/removeEventListener'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/onremovetrack.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/onremovetrack.html new file mode 100644 index 000000000..b8da16ce2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/onremovetrack.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>TextTrackList.onremovetrack</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +setup(function(){ + window.tracks = document.createElement('video').textTracks; + window.ev = new Event('removetrack'); + window.ran = false; + window.cb = function() { ran = true; }; +}); +test(function(){ + assert_equals(tracks.onremovetrack, null); + tracks.onremovetrack = cb; + assert_equals(tracks.onremovetrack, cb); + tracks.dispatchEvent(ev); + assert_true(ran); + tracks.onremovetrack = null; + ran = false; + tracks.dispatchEvent(ev); + assert_false(ran); +}); +test(function(){ + tracks.addEventListener('removetrack', cb, false); + tracks.dispatchEvent(ev); + assert_true(ran); + tracks.removeEventListener('removetrack', cb, false); + ran = false; + tracks.dispatchEvent(ev); + assert_false(ran); +}, 'TextTrackList.addEventListener/removeEventListener'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TrackEvent/constructor.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TrackEvent/constructor.html new file mode 100644 index 000000000..54567d14a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TrackEvent/constructor.html @@ -0,0 +1,24 @@ +<!doctype html> +<title>TrackEvent constructor</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + var ev = new TrackEvent('foo'); + assert_true(ev instanceof TrackEvent, 'ev instanceof TrackEvent'); + assert_true(ev instanceof Event, 'ev instanceof Event'); + assert_equals(ev.track, null, 'ev.track'); + ev.track = {}; + assert_equals(ev.track, null, 'ev.track after assignment'); +}, document.title+', one arg'); +test(function(){ + var obj = {}; + var ev = new TrackEvent('foo', {track:obj}); + assert_true(ev instanceof TrackEvent, 'ev instanceof TrackEvent'); + assert_true(ev instanceof Event, 'ev instanceof Event'); + assert_equals(ev.track, obj, 'ev.track'); + ev.track = {}; + assert_equals(ev.track, obj, 'ev.track after assignment'); +}, document.title+', two args'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TrackEvent/createEvent.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TrackEvent/createEvent.html new file mode 100644 index 000000000..9bf763f1f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TrackEvent/createEvent.html @@ -0,0 +1,15 @@ +<!doctype html> +<title>TrackEvent created with createEvent</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function(){ + // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17268 + assert_throws('NOT_SUPPORTED_ERR', function() { + var ev = document.createEvent('TrackEvent'); + }); + var ev = new TrackEvent('foo'); + assert_false('initTrackEvent' in ev, 'initTrackEvent'); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/autoplay-overrides-preload.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/autoplay-overrides-preload.html new file mode 100644 index 000000000..91103c586 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/autoplay-overrides-preload.html @@ -0,0 +1,28 @@ +<!DOCTYPE HTML> +<title>autoplay overrides preload</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id=log></div> +<script> +['none', 'metadata'].forEach(function(preload) { + ['first', 'last'].forEach(function(order) { + async_test(function(t) { + var a = document.createElement('audio'); + a.src = getAudioURI('/media/sound_5'); + if (order == 'first') { + a.autoplay = true; + a.preload = preload; + } else { + a.preload = preload; + a.autoplay = true; + } + a.addEventListener('playing', t.step_func(function() { + assert_equals(a.readyState, a.HAVE_ENOUGH_DATA); + assert_false(a.paused); + t.done(); + })); + }, 'autoplay (set ' + order + ') overrides preload "' + preload + '"'); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/load-events-networkState.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/load-events-networkState.html new file mode 100644 index 000000000..8c12011ef --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/load-events-networkState.html @@ -0,0 +1,67 @@ +<!doctype html> +<title>load() fires abort/emptied events when networkState is not NETWORK_EMPTY</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id=log></div> +<script> +function load_test(t, v) { + assert_not_equals(v.networkState, v.NETWORK_EMPTY); + + var expected_events = []; + if (v.networkState == v.NETWORK_LOADING || v.networkState == v.NETWORK_IDLE) { + expected_events.push('abort'); + } + if (v.networkState != v.NETWORK_EMPTY) { + expected_events.push('emptied'); + } + + var actual_events = []; + v.onabort = v.onemptied = t.step_func(function(e) { + actual_events.push(e.type); + }); + + v.onloadstart = t.step_func(function() { + assert_array_equals(actual_events, expected_events); + t.done(); + }); + + v.load(); + + assert_array_equals(actual_events, [], 'events should be fired in queued tasks'); +} + +async_test(function(t) { + var v = document.createElement('video'); + // suspend is fired optionally "if the user agent intends to not attempt to + // fetch the resource" or "once the entire media resource has been fetched" + v.preload = 'none'; + v.src = getAudioURI('/media/sound_5'); + v.onsuspend = t.step_func(function() { + v.onsuspend = null; + assert_equals(v.networkState, v.NETWORK_IDLE); + load_test(t, v); + }); +}, 'NETWORK_IDLE'); + +async_test(function(t) { + var v = document.createElement('video'); + v.src = 'resources/delayed-broken-video.py'; + v.onloadstart = t.step_func(function() { + v.onloadstart = null; + assert_equals(v.networkState, v.NETWORK_LOADING); + load_test(t, v); + }); +}, 'NETWORK_LOADING'); + +async_test(function(t) { + var v = document.createElement('video'); + v.src = 'data:,'; + v.onerror = t.step_func(function() { + v.onerror = null; + assert_equals(v.networkState, v.NETWORK_NO_SOURCE); + load_test(t, v); + }); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE); +}, 'NETWORK_NO_SOURCE'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/load-removes-queued-error-event.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/load-removes-queued-error-event.html new file mode 100644 index 000000000..54d5c28da --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/load-removes-queued-error-event.html @@ -0,0 +1,44 @@ +<!doctype html> +<title>load() removes queued error event</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +// The loadstart and error event firing tasks are queued in the synchronous +// section of the resource selection algorithm, so no tasks can come between +// them. Calling load() in the loadstart event handler removes the queued error +// event task at very latest opportunity, failing any implementation that fires +// the events in the same task. + +async_test(function(t) { + var v = document.createElement('video'); + var events = []; + v.onloadstart = v.onerror = t.step_func(function(e) { + events.push(e.type); + if (events.length == 1) { + v.load(); + } else if (events.length == 3) { + assert_array_equals(events, ['loadstart', 'loadstart', 'error']); + t.done(); + } + }); + v.src = ''; +}, 'video error event'); + +async_test(function(t) { + var v = document.createElement('video'); + var s = document.createElement('source'); + var events = []; + v.onloadstart = s.onerror = t.step_func(function(e) { + events.push(e.type); + if (events.length == 1) { + v.load(); + } else if (events.length == 3) { + assert_array_equals(events, ['loadstart', 'loadstart', 'error']); + t.done(); + } + }); + v.onerror = t.step_func(function() { assert_unreached(); }); + v.appendChild(s); +}, 'source error event'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-insert-before.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-insert-before.html new file mode 100644 index 000000000..39c988750 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-insert-before.html @@ -0,0 +1,29 @@ +<!doctype html> +<title>inserting another source before the candidate</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +function createSource(src) { + var source = document.createElement('source'); + source.src = src; + return source; +} +var t = async_test(function(t) { + v = document.createElement('video'); + v.addEventListener('loadstart', t.step_func(function() { + assert_equals(v.currentSrc.substr(v.currentSrc.lastIndexOf('#')), '#a'); + t.done(); + }), false); + v.appendChild(createSource('#a')); // invokes resource selection +}); +</script> +<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) --> +<!-- #a is candidate --> +<!-- pointer is between #a and the end of the list --> +<script> +t.step(function() { + v.insertBefore(createSource('#b'), v.firstChild); // pointer is unchanged, #a is still candidate +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-moved.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-moved.html new file mode 100644 index 000000000..f59452e0d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-moved.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>moving the candidate source</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var s; +var t = async_test(function(t) { + var v = document.createElement('video'); + s = document.createElement('source'); + s.src = 'resources/delayed-broken-video.py'; + s.onerror = t.step_func(function() { t.done(); }); + v.appendChild(s); // invokes resource selection + onload = t.step_func(function() { assert_unreached(); }); +}); +</script> +<script> +t.step(function() { + document.body.appendChild(s); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-addEventListener.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-addEventListener.html new file mode 100644 index 000000000..0c1e6f0ad --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-addEventListener.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>removing the candidate source, addEventListener</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +function createSource(src) { + var source = document.createElement('source'); + source.src = src; + return source; +} +var t = async_test(function(t) { + v = document.createElement('video'); + v.appendChild(createSource('resources/delayed-broken-video.py')); // invokes resource selection + v.firstChild.addEventListener('error', t.step_func(function() { t.done(); }), false); +}); +</script> +<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) --> +<!-- the <source> is candidate --> +<!-- pointer is between the <source> and the end of the list --> +<script> +t.step(function() { + v.removeChild(v.firstChild); // tests that we fire 'error' on it despite being removed +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-no-listener.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-no-listener.html new file mode 100644 index 000000000..f384eb312 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-no-listener.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>removing the candidate source, no listener</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +function createSource(src) { + var source = document.createElement('source'); + source.src = src; + return source; +} +var t = async_test(function(t) { + v = document.createElement('video'); + v.appendChild(createSource('resources/delayed-broken-video.py')); // invokes resource selection +}); +</script> +<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) --> +<!-- the <source> is candidate --> +<!-- pointer is between the <source> and the end of the list --> +<script> +t.step(function() { + v.removeChild(v.firstChild); // just tests that we don't crash + onload = t.step_func(function() { t.done(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-onerror.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-onerror.html new file mode 100644 index 000000000..c295c85bf --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-onerror.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>removing the candidate source, onerror</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +function createSource(src) { + var source = document.createElement('source'); + source.src = src; + return source; +} +var t = async_test(function(t) { + v = document.createElement('video'); + v.appendChild(createSource('resources/delayed-broken-video.py')); // invokes resource selection + v.firstChild.onerror = t.step_func(function() { t.done(); }); +}); +</script> +<!-- now resource selection algorithm will continue its sync section (the </script> tag below provides a stable state) --> +<!-- the <source> is candidate --> +<!-- pointer is between the <source> and the end of the list --> +<script> +t.step(function() { + v.removeChild(v.firstChild); // tests that we fire 'error' on it despite being removed +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-audio-constructor-no-src.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-audio-constructor-no-src.html new file mode 100644 index 000000000..cb2a57959 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-audio-constructor-no-src.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>NOT invoking resource selection with new Audio() sans src</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var a = new Audio(); + assert_equals(a.networkState, a.NETWORK_EMPTY); + a.onloadstart = t.step_func(function() { assert_unreached(); }); + window.onload = t.step_func(function() { t.done(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-audio-constructor.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-audio-constructor.html new file mode 100644 index 000000000..662129756 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-audio-constructor.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>invoking resource selection with new Audio(src)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var a = new Audio(''); + a.onloadstart = t.step_func(function() { t.done(); }); + window.onload = t.step_func(function() { assert_unreached(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-in-sync-event.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-in-sync-event.html new file mode 100644 index 000000000..55fc7c20d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-in-sync-event.html @@ -0,0 +1,32 @@ +<!doctype html> +<title>await a stable state and sync event handlers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video></video> +<script> +var v; +var t = async_test(function(t) { + v = document.querySelector('video'); + var a = document.createElement('a'); + a.onclick = t.step_func(function() { + v.setAttribute('src', '#'); // invokes media load which invokes resource selection + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in onclick handler'); + }); + a.click(); // sync fires click, so sets src + // now we should still await a stable state because the script hasn't + // finished, the event handler has just returned + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after click()'); + v.removeAttribute('src'); +}); +</script> +<script> +t.step(function() { + // now the sync section of resource selection should have run and should + // have found no src="" or <source> thus networkState being set to NETWORK_EMPTY. + // if the sync section was run when onclick returned, then networkState + // would be either NETWORK_LOADING or NETWORK_NO_SOURCE. + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script'); + t.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-fragment-into-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-fragment-into-document.html new file mode 100644 index 000000000..5d4c32f67 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-fragment-into-document.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>NOT invoking resource selection by inserting document fragment into a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + var fragment = document.createDocumentFragment(); + fragment.appendChild(v); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after fragment.appendChild(v)'); + document.body.appendChild(fragment); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after document.body.appendChild(fragment)'); +}); +</script> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script'); + t.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-into-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-into-document.html new file mode 100644 index 000000000..2f9ec978a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-into-document.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>NOT invoking resource selection by inserting into a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function(t) { + var v = document.createElement('video'); + document.body.appendChild(v); + assert_equals(v.networkState, v.NETWORK_EMPTY); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-into-iframe.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-into-iframe.html new file mode 100644 index 000000000..45d133d87 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-into-iframe.html @@ -0,0 +1,23 @@ +<!doctype html> +<title>NOT invoking resource selection by inserting into other document with src set</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<iframe hidden></iframe> +<script> +async_test(function(t) { + var v = document.createElement('video'); + v.src = 'data:,'; + v.onerror = t.step_func(function() { + assert_equals(v.readyState, v.HAVE_NOTHING); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE); + var iframe = document.querySelector('iframe'); + iframe.contentDocument.body.appendChild(v); + v.onloadstart = t.step_func(function() { assert_unreached(); }); + // wait for an event after the above + var v2 = document.createElement('video'); + v2.src = 'data:,'; + v2.onloadstart = t.step_func(function() { t.done(); }); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-parent-into-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-parent-into-document.html new file mode 100644 index 000000000..6da34344f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-parent-into-document.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>NOT invoking resource selection by inserting parent into a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var v = document.createElement('video'); + var div = document.createElement('div'); + div.appendChild(v); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after div.appendChild(v)'); + document.body.appendChild(div); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after document.body.appendChild(div)'); + window.onload = t.step_func(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in window.onload'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-in-div.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-in-div.html new file mode 100644 index 000000000..b79bea52f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-in-div.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>NOT invoking resource selection by inserting <source> in <div> in <video></title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video><div></div></video> +<script> +async_test(function(t) { + var v = document.querySelector('video'); + v.onloadstart = t.step_func(function() { assert_unreached(); }); + v.firstChild.appendChild(document.createElement('source')); + window.onload = t.step_func(function() { t.done(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-in-namespace.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-in-namespace.html new file mode 100644 index 000000000..b73f229ec --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-in-namespace.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>NOT invoking resource selection by inserting <source> in the wrong namespace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video></video> +<script> +async_test(function(t) { + var v = document.querySelector('video'); + v.onloadstart = t.step_func(function() { assert_unreached(); }); + v.appendChild(document.createElementNS('bogus','source')); + window.onload = t.step_func(function() { t.done(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-networkState.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-networkState.html new file mode 100644 index 000000000..5ef6e4cb3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-networkState.html @@ -0,0 +1,38 @@ +<!doctype html> +<title>NOT invoking resource selection by inserting <source> when networkState is not NETWORK_EMPTY</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var loadstartCount = 0; +var s1ErrorCount = 0; +var s2ErrorCount = 0; +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + v.onloadstart = function() { loadstartCount++; }; + var s1 = document.createElement('source'); + s1.src = 'resources/delayed-broken-video.py'; + s1.onerror = function() { s1ErrorCount++; }; + v.appendChild(s1); // invokes resource selection + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in first script'); +}); +</script> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_LOADING, 'networkState in second script'); + assert_equals(s1ErrorCount, 0, 's1ErrorCount in second script'); + var s2 = document.createElement('source'); + s2.onerror = t.step_func(function() { + s2ErrorCount++; + assert_equals(s1ErrorCount, 1, 's1ErrorCount in s2.onerror'); + }); + v.appendChild(s2); + onload = t.step_func(function() { + assert_equals(s2ErrorCount, 1, 's2ErrorCount in window.onload'); + assert_equals(loadstartCount, 1, 'loadstartCount in window.onload'); // reliable if https://www.w3.org/Bugs/Public/show_bug.cgi?id=24353 is fixed + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in window.onload'); // See Waiting step + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-not-in-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-not-in-document.html new file mode 100644 index 000000000..2007b2e8b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-not-in-document.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>invoking resource selection by inserting <source> in video not in a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var v = document.createElement('video'); + v.onloadstart = t.step_func(function() { t.done(); }); + v.appendChild(document.createElement('source')); + window.onload = t.step_func(function() { assert_unreached(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source.html new file mode 100644 index 000000000..969daad62 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>invoking resource selection by inserting <source></title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video></video> +<script> +async_test(function(t) { + var v = document.querySelector('video'); + v.onloadstart = t.step_func(function() { t.done(); }); + v.appendChild(document.createElement('source')); + window.onload = t.step_func(function() { assert_unreached(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-load.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-load.html new file mode 100644 index 000000000..909c72cd1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-load.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>invoking resource selection with load()</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after creating v'); + v.load(); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after v.load()'); +}); +</script> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script'); + t.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-pause-networkState.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-pause-networkState.html new file mode 100644 index 000000000..18561a264 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-pause-networkState.html @@ -0,0 +1,28 @@ +<!doctype html> +<title>NOT invoking resource selection with pause() when networkState is not NETWORK_EMPTY</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video></video> +<script> +var v; +var t = async_test(function(t) { + v = document.querySelector('video'); + v.src = 'data:,'; + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after setting src'); + var errorCount = 0; + v.onerror = t.step_func(function() { + errorCount++; + if (errorCount == 1) { + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in onerror'); + v.pause(); // should not invoke RSA. if it does, error will be fired again. + } else { + assert_unreached(); + } + }); + onload = t.step_func(function() { + assert_equals(errorCount, 1, 'errorCount'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-pause.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-pause.html new file mode 100644 index 000000000..4f1bca74d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-pause.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>invoking resource selection with pause()</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after creating v'); + v.pause(); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after v.pause()'); +}); +</script> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script'); + t.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-play.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-play.html new file mode 100644 index 000000000..64a440080 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-play.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>invoking resource selection with play()</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after creating v'); + v.play(); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after v.play()'); +}); +</script> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script'); + t.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-from-document-networkState.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-from-document-networkState.html new file mode 100644 index 000000000..1eed276b2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-from-document-networkState.html @@ -0,0 +1,29 @@ +<!doctype html> +<title>NOT invoking resource selection with implicit pause() when networkState is not NETWORK_EMPTY</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video></video> +<script> +var v; +var t = async_test(function(t) { + v = document.querySelector('video'); + v.src = 'data:,'; + document.body.appendChild(v); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after setting src'); + var errorCount = 0; + v.onerror = t.step_func(function() { + errorCount++; + if (errorCount == 1) { + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in onerror'); + document.body.removeChild(v); // invokes pause() which should not invoke RSA. if it does, error will be fired again. + } else { + assert_unreached(); + } + }); + onload = t.step_func(function() { + assert_equals(errorCount, 1, 'errorCount'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-from-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-from-document.html new file mode 100644 index 000000000..23e7104ca --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-from-document.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>NOT invoking resource selection by removing from document with NETWORK_EMPTY</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + document.body.appendChild(v); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after appending v to document'); + v.parentNode.removeChild(v); // search for "When a media element is removed from a Document," + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after removing v'); +}); +</script> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate script'); + t.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-src.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-src.html new file mode 100644 index 000000000..6302ffeac --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-remove-src.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>NOT invoking media load or resource selection when removing the src attribute</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + v.setAttribute('src', ''); // invokes media load + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after setting src'); + var s = document.createElement('source'); + s.onerror = this.step_func(function() { assert_unreached(); }); + v.appendChild(s); // src is present so nothing happens here + onload = this.step_func(function() { t.done(); }); +}); +</script> +<script> +t.step(function() { + v.removeAttribute('src'); // nothing should happen +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-in-namespace.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-in-namespace.html new file mode 100644 index 000000000..438db124d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-in-namespace.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>NOT invoking load by setting src in the wrong namespace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video></video> +<script> +async_test(function(t) { + var v = document.querySelector('video'); + v.onloadstart = t.step_func(function() { assert_unreached(); }); + v.setAttributeNS('bogus','src', ''); + window.onload = t.step_func(function() { t.done(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html new file mode 100644 index 000000000..e195dedb0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>invoking load by setting src when networkState is not NETWORK_EMPTY</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function(t) { + var v = document.createElement('video'); + v.play(); // invokes resource selection and sets .paused to false + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState'); + assert_false(v.paused, 'paused'); + v.setAttribute('src', ''); // invokes media load which sets .paused to true + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after setting src'); + assert_true(v.paused, 'paused after setting src'); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-not-in-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-not-in-document.html new file mode 100644 index 000000000..f6c4f2406 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-not-in-document.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>invoking load by setting src on video not in a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var v = document.createElement('video'); + v.onloadstart = t.step_func(function() { t.done(); }); + v.setAttribute('src',''); + window.onload = t.step_func(function() { assert_unreached(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src.html new file mode 100644 index 000000000..e04b1b058 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>invoking load by setting src</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video></video> +<script> +async_test(function(t) { + var v = document.querySelector('video'); + v.onloadstart = t.step_func(function() { t.done(); }); + v.setAttribute('src', ''); + window.onload = t.step_func(function() { assert_unreached(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-control.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-control.html new file mode 100644 index 000000000..dad5e5fd0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-control.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>pointer updates (control test)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var a = 0; +var b = 0; +var c = 0; +</script> +<video + ><source onerror=a++ + ><source onerror=b++ src='resources/delayed-broken-video.py' + ><source onerror=c++ + ></video +> +<script> +async_test(function(t) { + window.onload = t.step_func(function() { + assert_equals(a, 1, 'error events on a'); + assert_equals(b, 1, 'error events on b'); + assert_equals(c, 1, 'error events on c'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-br.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-br.html new file mode 100644 index 000000000..3ee141e30 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-br.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>pointer updates (adding br elements)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var a = 0; +var b = 0; +var c = 0; +</script> +<video + ><source onerror=a++ + ><source onerror=b++ src='resources/delayed-broken-video.py' + ><source onerror=c++ + ></video +> +<script> +async_test(function(t) { + var video = document.querySelector('video'); + // add br elements + var br = document.createElement('br'); + video.insertBefore(br, video.querySelector('[onerror="a++"]')); + video.insertBefore(br.cloneNode(false), video.querySelector('[onerror="b++"]')); + video.insertBefore(br.cloneNode(false), video.querySelector('[onerror="c++"]')); + video.appendChild(br.cloneNode(false)); + window.onload = t.step_func(function() { + assert_equals(a, 1, 'error events on a'); + assert_equals(b, 1, 'error events on b'); + assert_equals(c, 1, 'error events on c'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-source.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-source.html new file mode 100644 index 000000000..2d32e6fca --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-source.html @@ -0,0 +1,44 @@ +<!doctype html> +<title>pointer updates (adding source elements)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var a = 0; +var b = 0; +var c = 0; +var x1 = 0; +var x2 = 0; +var x3 = 0; +var x4 = 0; +</script> +<video + ><source onerror=a++ + ><source onerror=b++ src='resources/delayed-broken-video.py' + ><source onerror=c++ + ></video +> +<script> +async_test(function(t) { + var video = document.querySelector('video'); + // add source elements + var source1 = document.createElement('source'); source1.onerror = function() { x1++; }; + var source2 = document.createElement('source'); source2.onerror = function() { x2++; }; + var source3 = document.createElement('source'); source3.onerror = function() { x3++; }; + var source4 = document.createElement('source'); source4.onerror = function() { x4++; }; + video.insertBefore(source1, video.querySelector('[onerror="a++"]')); + video.insertBefore(source2, video.querySelector('[onerror="b++"]')); + video.insertBefore(source3, video.querySelector('[onerror="c++"]')); + video.appendChild(source4); + window.onload = t.step_func(function() { + assert_equals(a, 1, 'error events on a'); + assert_equals(b, 1, 'error events on b'); + assert_equals(c, 1, 'error events on c'); + assert_equals(x1, 0, 'error events on x1'); + assert_equals(x2, 0, 'error events on x2'); + assert_equals(x3, 1, 'error events on x3'); + assert_equals(x4, 1, 'error events on x4'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-text.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-text.html new file mode 100644 index 000000000..15a4e4be0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-insert-text.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>pointer updates (adding text nodes)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var a = 0; +var b = 0; +var c = 0; +</script> +<video + ><source onerror=a++ + ><source onerror=b++ src='resources/delayed-broken-video.py' + ><source onerror=c++ + ></video +> +<script> +async_test(function(t) { + var video = document.querySelector('video'); + // add text nodes + var text = document.createTextNode('x'); + video.insertBefore(text, video.querySelector('[onerror="a++"]')); + video.insertBefore(text.cloneNode(false), video.querySelector('[onerror="b++"]')); + video.insertBefore(text.cloneNode(false), video.querySelector('[onerror="c++"]')); + video.appendChild(text.cloneNode(false)); + window.onload = t.step_func(function() { + assert_equals(a, 1, 'error events on a'); + assert_equals(b, 1, 'error events on b'); + assert_equals(c, 1, 'error events on c'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-source-after.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-source-after.html new file mode 100644 index 000000000..0d1c94037 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-source-after.html @@ -0,0 +1,56 @@ +<!doctype html> +<title>pointer updates (removing source element after pointer)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var a = 0; +var b = 0; +var c = 0; +var x1 = 0; +var x2 = 0; +var x3 = 0; +var x4 = 0; +</script> +<video + ><source onerror=a++ + ><source onerror=b++ src='resources/delayed-broken-video.py' + ><source onerror=x1++ + ><source onerror=x2++ + ><source onerror=x3++ + ><source onerror=x4++ + ><source onerror=c++ + ></video +> +<script> +var v; +var t = async_test(function(t) { + v = document.querySelector('video'); + v.removeChild(document.querySelector('[onerror="x1++"]')); + window.onload = t.step_func(function() { + assert_equals(a, 1, 'error events on a'); + assert_equals(b, 1, 'error events on b'); + assert_equals(c, 1, 'error events on c'); + assert_equals(x1, 0, 'error events on x1'); + assert_equals(x2, 0, 'error events on x2'); + assert_equals(x3, 0, 'error events on x3'); + assert_equals(x4, 0, 'error events on x4'); + t.done(); + }); +}); +</script> +<script> +t.step(function() { + v.removeChild(document.querySelector('[onerror="x2++"]')); +}); +</script> +<script> +t.step(function() { + v.removeChild(document.querySelector('[onerror="x3++"]')); +}); +</script> +<script> +t.step(function() { + v.removeChild(document.querySelector('[onerror="x4++"]')); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-source.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-source.html new file mode 100644 index 000000000..191f9b5e2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-source.html @@ -0,0 +1,43 @@ +<!doctype html> +<title>pointer updates (removing source elements)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var a = 0; +var b = 0; +var c = 0; +var x1 = 0; +var x2 = 0; +var x3 = 0; +var x4 = 0; +</script> +<video + ><source onerror=x1++ + ><source onerror=a++ + ><source onerror=x2++ + ><source onerror=b++ src='resources/delayed-broken-video.py' + ><source onerror=x3++ + ><source onerror=c++ + ><source onerror=x4++ + ></video +> +<script> +async_test(function(t) { + var video = document.querySelector('video'); + // remove the xn elements + [].forEach.call(document.querySelectorAll('[onerror^="x"]'), function(elm) { + video.removeChild(elm); + }); + window.onload = t.step_func(function() { + assert_equals(a, 1, 'error events on a'); + assert_equals(b, 1, 'error events on b'); + assert_equals(c, 1, 'error events on c'); + assert_equals(x1, 1, 'error events on x1'); + assert_equals(x2, 1, 'error events on x2'); + assert_equals(x3, 0, 'error events on x3'); + assert_equals(x4, 0, 'error events on x4'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-text.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-text.html new file mode 100644 index 000000000..f0fe5da90 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-text.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>pointer updates (removing text nodes)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var a = 0; +var b = 0; +var c = 0; +</script> +<video + >x<source onerror=a++ + >x<source onerror=b++ src='resources/delayed-broken-video.py' + >x<source onerror=c++ + >x</video +> +<script> +async_test(function(t) { + var video = document.querySelector('video'); + // remove the text nodes + [].forEach.call(video.childNodes, function(node) { + if (node.nodeType == node.TEXT_NODE) { + video.removeChild(node); + } + }); + window.onload = t.step_func(function() { + assert_equals(a, 1, 'error events on a'); + assert_equals(b, 1, 'error events on b'); + assert_equals(c, 1, 'error events on c'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-remove-source.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-remove-source.html new file mode 100644 index 000000000..fbeead019 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-remove-source.html @@ -0,0 +1,24 @@ +<!doctype html> +<title>Changes to networkState when inserting and removing a <source></title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState when creating the element'); + v.appendChild(document.createElement('source')); // runs resource selection algorithm + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState when inserting a source element'); + v.removeChild(v.firstChild); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after removing the source element'); +}); +</script> +<!-- now resource selection will continue its sync section (the </script> tag below provides a stable state) --> +<!-- will find neither src nor source, so sets networkState to NETWORK_EMPTY --> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState after letting the sync section of resource selection run'); + t.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-remove-src.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-remove-src.html new file mode 100644 index 000000000..4d7887182 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-remove-src.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>invoking resource selection by setting src; await stable state</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var v; +var t = async_test(function(t) { + v = document.createElement('video'); + v.onloadstart = t.step_func(function() { assert_unreached(); }); + v.setAttribute('src', ''); // runs resource selection algorithm, but it will wait running the sync section until this script has finished + assert_equals(v.networkState, v.NETWORK_NO_SOURCE); + v.removeAttribute('src'); // will make resource selection algorithm revert to NETWORK_EMPTY and abort (in the sync section) + assert_equals(v.networkState, v.NETWORK_NO_SOURCE); + window.onload = t.step_func(function() { t.done(); }); +}); +</script> +<script> +t.step(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-source-media.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-source-media.html new file mode 100644 index 000000000..6332f0890 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-source-media.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>the <source> media attribute has no effect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<video><source src="resources/delayed-broken-video.py" media="none"></video> +<script> +test(function() { + var v = document.querySelector('video'); + var s = document.querySelector('source'); + assert_equals(v.networkState, v.NETWORK_LOADING); + assert_equals(v.currentSrc, s.src); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resources/delayed-broken-video.py b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resources/delayed-broken-video.py new file mode 100644 index 000000000..88e502794 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resources/delayed-broken-video.py @@ -0,0 +1,5 @@ +import time + +def main(request, response): + time.sleep(0.1) + return [("Content-Type", "text/plain")], "FAIL" diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-beforeunload-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-beforeunload-manual.html new file mode 100644 index 000000000..61ed225fa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-beforeunload-manual.html @@ -0,0 +1,30 @@ +<!doctype html> +<title>stable state in beforeunload</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<button>click this button and cancel navigation</button> +<a href="data:text/plain,FAIL: did not cancel navigation"></a> +<script> +async_test(function(t) { + window.onbeforeunload = t.step_func(function(event) { + var message = "foo bar"; + event.returnValue = message; + return message; + }); + var button = document.querySelector('button'); + var link = document.querySelector('a'); + button.onclick = t.step_func(function() { + v = document.createElement('video'); + v.src = 'data:,'; + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState before dialog'); + assert_equals(v.currentSrc, '', 'currentSrc before dialog'); + link.click(); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after dialog'); + assert_equals(v.currentSrc, '', 'currentSrc after dialog'); + t.done(); + window.onbeforeonload = null; + button.remove(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-dialogs-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-dialogs-manual.html new file mode 100644 index 000000000..267dde913 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-dialogs-manual.html @@ -0,0 +1,18 @@ +<!doctype html> +<title>stable state in dialogs</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +['alert', 'confirm', 'prompt'].forEach(function(dialog) { + test(function() { + v = document.createElement('video'); + v.src = 'data:,'; + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState before dialog'); + assert_equals(v.currentSrc, '', 'currentSrc before dialog'); + window[dialog]('dismiss this dialog'); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after dialog'); + assert_equals(v.currentSrc, '', 'currentSrc after dialog'); + }, 'stable state in ' + dialog + '()'); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-print-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-print-manual.html new file mode 100644 index 000000000..1261a0079 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/stable-state-print-manual.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>stable state in print()</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<button>click this button and dismiss the print dialog</button> +<script> +async_test(function(t) { + var button = document.querySelector('button'); + button.onclick = t.step_func(function() { + v = document.createElement('video'); + v.src = 'data:,'; + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState before dialog'); + assert_equals(v.currentSrc, '', 'currentSrc before dialog'); + print(); + assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after dialog'); + assert_equals(v.currentSrc, '', 'currentSrc after dialog'); + t.done(); + button.remove(); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/location-of-the-media-resource/currentSrc.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/location-of-the-media-resource/currentSrc.html new file mode 100644 index 000000000..2ca0a5180 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/location-of-the-media-resource/currentSrc.html @@ -0,0 +1,44 @@ +<!doctype html> +<title>currentSrc</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +['audio', 'video'].forEach(function(tagName) { + test(function() { + assert_equals(document.createElement(tagName).currentSrc, ''); + }, tagName + '.currentSrc initial value'); + + ['', '.', ' ', 'data:,'].forEach(function(src) { + async_test(function(t) { + var e = document.createElement(tagName); + e.src = src; + assert_equals(e.currentSrc, ''); + setTimeout(t.step_func(function() { + if (src == '') { + assert_equals(e.currentSrc, ''); + } else { + assert_equals(e.currentSrc, e.src); + } + t.done(); + }), 0); + }, tagName + '.currentSrc after setting src attribute "' + src + '"'); + + async_test(function(t) { + var e = document.createElement(tagName); + var s = document.createElement('source'); + s.src = src; + e.appendChild(s); + assert_equals(e.currentSrc, ''); + setTimeout(t.step_func(function() { + if (src == '') { + assert_equals(e.currentSrc, ''); + } else { + assert_equals(e.currentSrc, s.src); + } + t.done(); + }), 0); + }, tagName + '.currentSrc after adding source element with src attribute "' + src + '"'); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/mime-types/canPlayType.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/mime-types/canPlayType.html new file mode 100644 index 000000000..c5d37e752 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/mime-types/canPlayType.html @@ -0,0 +1,110 @@ +<!doctype html> +<title>canPlayType</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +function t(type, expected) { + assert_equals(canPlayType(type), expected, type); +} + +function mime(type, codecs) { + if (codecs.length) { + return type + '; codecs="' + codecs.join(', ') + '"'; + } + return type; +} + +test(function() { + assert_equals(mime('video/webm', []), 'video/webm'); + assert_equals(mime('video/webm', ['vp8']), 'video/webm; codecs="vp8"'); + assert_equals(mime('video/webm', ['vp8', 'vorbis']), 'video/webm; codecs="vp8, vorbis"'); +}, 'utility code'); + +function canPlayType(type) { + var canPlay = document.createElement('audio').canPlayType(type); + assert_equals(canPlay, document.createElement('video').canPlayType(type), + 'audio.canPlayType() and video.canPlayType() agree'); + assert_in_array(canPlay, ['', 'maybe', 'probably'], + 'return value is one of "", "maybe" and "probably"'); + return canPlay; +} + +test(function() { + t('application/octet-stream', ''); + t('application/octet-stream; codecs="vorbis"', ''); + t('application/octet-stream; codecs="vp8, vorbis"', ''); + t('application/octet-stream; codecs="mp4a.40.2"', ''); + t('application/octet-stream; codecs="theora, vorbis"', ''); + t('application/octet-stream; codecs="avc1.42E01E, mp4a.40.2"', ''); +}, 'application/octet-stream'); + +test(function() { + t('video/x-new-fictional-format', ''); + t('video/x-new-fictional-format;codecs="kittens,bunnies"', ''); +}, 'video/x-new-fictional-format'); + +function type_codecs_test(type, audioCodecs, videoCodecs) { + var typeSupported = false; + var codecSupported = false; + + test(function() { + // Spec: Generally, a user agent should never return "probably" for a type + // that allows the codecs parameter if that parameter is not present. + t(type, 'maybe'); + typeSupported = true; + }, type + ' (optional)'); + + function test_codec(codec) { + var typeWithCodec = mime(type, [codec]); + test(function() { + t(typeWithCodec, 'probably'); + codecSupported = true; + }, typeWithCodec + ' (optional)'); + } + + audioCodecs.forEach(test_codec); + videoCodecs.forEach(test_codec); + + if (audioCodecs.length > 0 && videoCodecs.length > 0) { + test(function() { + audioCodecs.forEach(function(ac) { + videoCodecs.forEach(function(vc) { + var canPlayBoth = canPlayType(mime(type, [ac, vc])); + if (canPlayBoth) { + t(mime(type, [ac]), canPlayBoth); + t(mime(type, [vc]), canPlayBoth); + } + }); + }); + }, type + ' codecs subset'); + + test(function() { + audioCodecs.forEach(function(ac) { + videoCodecs.forEach(function(vc) { + assert_equals(canPlayType(mime(type, [ac, vc])), + canPlayType(mime(type, [vc, ac]))); + }); + }); + }, type + ' codecs order'); + } + + test(function() { + t(mime(type, ['bogus']), ''); + }, type + ' with bogus codec'); + + test(function() { + // At least one known codec must be supported if the container format is. + assert_equals(typeSupported, codecSupported); + }, type + ' with and without codecs'); +} + +type_codecs_test('audio/mp4', ['mp4a.40.2'], []); +type_codecs_test('audio/ogg', ['opus', 'vorbis'], []); +type_codecs_test('audio/wav', ['1'], []); +type_codecs_test('audio/webm', ['opus', 'vorbis'], []); +type_codecs_test('video/3gpp', ['samr'], ['mp4v.20.8']); +type_codecs_test('video/mp4', ['mp4a.40.2'], ['avc1.42E01E', 'avc1.4D401E', 'avc1.58A01E', 'avc1.64001E', 'mp4v.20.8', 'mp4v.20.240']); +type_codecs_test('video/ogg', ['opus', 'vorbis'], ['theora']); +type_codecs_test('video/webm', ['opus', 'vorbis'], ['vp8', 'vp8.0', 'vp9', 'vp9.0']); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_during_loadstart.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_during_loadstart.html new file mode 100644 index 000000000..8f0fffc61 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_during_loadstart.html @@ -0,0 +1,42 @@ +<!doctype html> +<html> + <head> + <title>{audio,video}.networkState - NETWORK_LOADING</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#dom-media-networkstate">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +var ta = async_test("audioElement.networkState should be NETWORK_LOADING during loadstart event", {timeout:5000}); +var a = document.getElementById("a"); +a.addEventListener("loadstart", function() { + ta.step(function() { + assert_equals(a.networkState, + a.NETWORK_LOADING); + }); + ta.done(); + a.pause(); +}, false); +a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + +var tv = async_test("videoElement.networkState should be NETWORK_LOADING during loadstart event", {timeout:5000}); +var v = document.getElementById("v"); +v.addEventListener("loadstart", function() { + tv.step(function() { + assert_equals(a.networkState, + v.NETWORK_LOADING); + }); + tv.done(); + v.pause(); +}, false); +v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_during_progress.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_during_progress.html new file mode 100644 index 000000000..cf23e822c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_during_progress.html @@ -0,0 +1,42 @@ +<!doctype html> +<html> + <head> + <title>{audio,video}.networkState - NETWORK_LOADING</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#dom-media-networkstate">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +var ta = async_test("audioElement.networkState should be NETWORK_LOADING during progress event", {timeout:5000}); +var a = document.getElementById("a"); +a.addEventListener("progress", function() { + ta.step(function() { + assert_equals(a.networkState, + a.NETWORK_LOADING); + }); + ta.done(); + a.pause(); +}, false); +a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + +var tv = async_test("videoElement.networkState should be NETWORK_LOADING during progress event", {timeout:5000}); +var v = document.getElementById("v"); +v.addEventListener("progress", function() { + tv.step(function() { + assert_equals(v.networkState, + v.NETWORK_LOADING); + }); + tv.done(); + v.pause(); +}, false); +v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_initial.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_initial.html new file mode 100644 index 000000000..0a203e654 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/networkState_initial.html @@ -0,0 +1,33 @@ +<!doctype html> +<html> + <head> + <title>{audio,video}.networkState - default state</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#dom-media-networkstate">spec reference</a></p> + <audio id="a"> + </audio> + <video id="v"> + </video> + <div id="log"></div> + <script> +test(function() { + var a = document.getElementById("a"); + assert_equals( + a.networkState, + a.NETWORK_EMPTY, + "audioElement.networkState should be NETWORK_EMPTY to begin with"); +}, "audio.networkState - default state"); + +test(function() { + var v = document.getElementById("v"); + assert_equals( + v.networkState, + v.NETWORK_EMPTY, + "videoElement.networkState should be NETWORK_EMPTY to begin with"); +}, "video.networkState - default state"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/offsets-into-the-media-resource/currentTime.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/offsets-into-the-media-resource/currentTime.html new file mode 100644 index 000000000..e9b658994 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/offsets-into-the-media-resource/currentTime.html @@ -0,0 +1,32 @@ +<!doctype html> +<title>currentTime</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id=log></div> +<script> +test(function() { + var v = document.createElement('video'); + assert_equals(v.currentTime, 0); +}, 'currentTime initial value'); + +test(function() { + var v = document.createElement('video'); + assert_equals(v.readyState, v.HAVE_NOTHING); + v.currentTime = Number.MAX_VALUE; + assert_equals(v.currentTime, Number.MAX_VALUE); + assert_false(v.seeking); +}, 'setting currentTime when readyState is HAVE_NOTHING'); + +async_test(function(t) { + var v = document.createElement('video'); + v.src = getVideoURI('/media/movie_5'); + v.onloadedmetadata = t.step_func(function() { + assert_greater_than(v.readyState, v.HAVE_NOTHING); + assert_false(v.seeking); + v.currentTime = 1; + assert_true(v.seeking); + t.done(); + }); +}, 'setting currentTime when readyState is greater than HAVE_NOTHING'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/offsets-into-the-media-resource/duration.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/offsets-into-the-media-resource/duration.html new file mode 100644 index 000000000..0ac26eddb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/offsets-into-the-media-resource/duration.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>duration</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var v = document.createElement('video'); + assert_true(isNaN(v.duration)); +}, 'duration initial value'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/paused_false_during_play.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/paused_false_during_play.html new file mode 100644 index 000000000..28c563333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/paused_false_during_play.html @@ -0,0 +1,44 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - paused property</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("audio.paused should be false during play event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("play", function() { + t.step(function() { + assert_false(a.paused); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - paused property"); + +test(function() { + var t = async_test("video.paused should be false during play event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("play", function() { + t.step(function() { + assert_false(v.paused); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - paused property"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/paused_true_during_pause.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/paused_true_during_pause.html new file mode 100644 index 000000000..6c4eb7c0c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/paused_true_during_pause.html @@ -0,0 +1,46 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - paused property</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" controls> + </audio> + <video id="v" controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("audio.paused should be true during pause event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("pause", function() { + t.step(function() { + assert_true(a.paused); + }); + t.done(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); + a.play(); + a.pause(); +}, "audio events - paused property"); + +test(function() { + var t = async_test("video.paused should be true during pause event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("pause", function() { + t.step(function() { + assert_true(v.paused); + }); + t.done(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + v.play(); + v.pause(); +}, "video events - paused property"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html new file mode 100644 index 000000000..342771dbd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html @@ -0,0 +1,25 @@ +<!doctype html> +<title>paused state when moving to other document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id="log"></div> +<video hidden></video> +<iframe hidden></iframe> +<script> +async_test(function(t) { + var v = document.querySelector('video'); + v.src = getVideoURI('/media/movie_300'); + v.play(); + v.onplaying = t.step_func(function() { + assert_false(v.paused, 'paused after playing'); + document.querySelector('iframe').contentDocument.body.appendChild(v); + assert_false(v.paused, 'paused after moving'); + setTimeout(t.step_func(function() { + assert_false(v.paused, 'paused after stable state') + t.done(); + }), 0); + }); + v.onpause = t.step_func(function() { assert_unreached(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-within-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-within-document.html new file mode 100644 index 000000000..a28322d4d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-within-document.html @@ -0,0 +1,25 @@ +<!doctype html> +<title>paused state when moving within a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id="log"></div> +<video hidden></video> +<div id="elsewhere"></div> +<script> +async_test(function(t) { + var v = document.querySelector('video'); + v.src = getVideoURI('/media/movie_300'); + v.play(); + v.onplaying = t.step_func(function() { + assert_false(v.paused, 'paused after playing'); + document.getElementById('elsewhere').appendChild(v); + assert_false(v.paused, 'paused after moving'); + setTimeout(t.step_func(function() { + assert_false(v.paused, 'paused after stable state') + t.done(); + }), 0); + }); + v.onpause = t.step_func(function() { assert_unreached(); }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html new file mode 100644 index 000000000..3b5849a35 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>paused state when removing from a document when networkState is NETWORK_EMPTY</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<video hidden></video> +<script> +// Negative test for the specified behavior prior to HTML r8447. +async_test(function(t) { + var v = document.querySelector('video'); + v.play(); + setTimeout(t.step_func(function() { + assert_equals(v.networkState, v.NETWORK_EMPTY, + 'networkState after stable state'); + assert_false(v.paused, 'paused after stable state'); + v.parentNode.removeChild(v); + assert_false(v.paused, 'paused after removing'); + v.onpause = t.step_func(function() { t.done(); }); + }), 0); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html new file mode 100644 index 000000000..7a4b0bc0d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html @@ -0,0 +1,37 @@ +<!doctype html> +<title>paused state when removing from a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id="log"></div> +<video hidden></video> +<script> +function afterStableState(func) { + var a = new Audio(); + a.volume = 0; + a.addEventListener('volumechange', func); +} + +async_test(function(t) { + var v = document.querySelector('video'); + v.src = getVideoURI('/media/movie_300'); + v.play(); + v.onplaying = t.step_func(function() { + assert_false(v.paused, 'paused after playing'); + v.parentNode.removeChild(v); + assert_false(v.paused, 'paused after removing'); + afterStableState(t.step_func(function() { + assert_true(v.paused, 'paused after stable state'); + v.onpause = t.step_func(function() { + assert_true(v.paused, 'paused in pause event'); + // re-insert and verify that it stays paused + document.body.appendChild(v); + setTimeout(t.step_func(function() { + assert_true(v.paused, 'paused after re-inserting'); + t.done(); + }), 0); + }); + })); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/play-in-detached-document.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/play-in-detached-document.html new file mode 100644 index 000000000..9c6fd5fab --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/play-in-detached-document.html @@ -0,0 +1,23 @@ +<!doctype html> +<title>play() in detached document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id="log"></div> +<script> +// Negative test for failure to play in a detached document. +async_test(function(t) +{ + var doc = document.implementation.createHTMLDocument(""); + var v = doc.createElement("video"); + doc.body.appendChild(v); + v.src = getVideoURI("/media/movie_5"); + v.play(); + v.addEventListener("timeupdate", t.step_func(function() { + assert_false(v.paused); + if (v.currentTime > 0) { + t.done(); + } + })); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/playbackRate.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/playbackRate.html new file mode 100644 index 000000000..fa11d9944 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/playbackRate.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>playbackRate</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var v = document.createElement('video'); + assert_equals(v.playbackRate, 1); +}, 'playbackRate initial value'); + +async_test(function(t) { + var v = document.createElement('video'); + v.playbackRate = 2; + v.addEventListener('ratechange', t.step_func(function() { + t.done(); + })); +}, 'setting playbackRate'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/preload_reflects_none_autoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/preload_reflects_none_autoplay.html new file mode 100644 index 000000000..2670b0dd8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/preload_reflects_none_autoplay.html @@ -0,0 +1,31 @@ +<!doctype html> +<html> + <head> + <title>{audio,video}.preload - reflection test</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#dom-media-preload">spec reference</a></p> + <audio id="audio" autoplay preload="none"> + </audio> + <video id="video" autoplay preload="none"> + </video> + <div id="log"></div> + <script> +test(function() { + assert_equals( + document.getElementById("audio").preload, + "none", + "audioElement.preload reflects 'none' value even if autoplay attribute is present"); +}, "audio.preload - reflection test"); + +test(function() { + assert_equals( + document.getElementById("video").preload, + "none", + "videoElement.preload reflects 'none' value even if autoplay attribute is present"); +}, "video.preload - reflection test"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html new file mode 100644 index 000000000..76aef1dbc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html @@ -0,0 +1,73 @@ +<!doctype html> +<title>autoplay</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id="log"></div> +<script> +function autoplay_test(tagName, src) { + function expect_events(t, e, expected_events) { + var actual_events = []; + var callback = t.step_func(function(ev) { + actual_events.push(ev.type); + assert_array_equals(actual_events, + expected_events.slice(0, actual_events.length)); + if (expected_events.length == actual_events.length) { + t.done(); + } + }); + ['canplay', 'canplaythrough', + 'pause', 'play', 'playing'].forEach(function(type) { + e.addEventListener(type, callback); + }); + } + + async_test(function(t) { + var e = document.createElement(tagName); + e.src = src; + e.autoplay = true; + expect_events(t, e, ['canplay', 'play', 'playing', 'canplaythrough']); + }, tagName + '.autoplay'); + + async_test(function(t) { + var e = document.createElement(tagName); + e.src = src; + e.autoplay = true; + e.pause(); // sets the autoplaying flag to false + e.load(); // sets the autoplaying flag to true + expect_events(t, e, ['canplay', 'play', 'playing', 'canplaythrough']); + }, tagName + '.autoplay and load()'); + + async_test(function(t) { + var e = document.createElement(tagName); + e.src = src; + e.autoplay = true; + e.play(); // sets the autoplaying flag to false + // play() also sets the paused attribute to false; there is no way for the + // autoplaying flag to be true when the paused attribute is false. + assert_equals(e.paused, false); + expect_events(t, e, ['play', 'canplay', 'playing', 'canplaythrough']); + }, tagName + '.autoplay and play()'); + + async_test(function(t) { + var e = document.createElement(tagName); + e.src = src; + e.autoplay = true; + e.pause(); // sets the autoplaying flag to false + expect_events(t, e, ['canplay', 'canplaythrough']); + }, tagName + '.autoplay and pause()'); + + async_test(function(t) { + var e = document.createElement(tagName); + e.src = src; + e.autoplay = true; + document.body.appendChild(e); + document.body.removeChild(e); + // in stable state, internal pause steps sets the autoplaying flag to false + expect_events(t, e, ['canplay', 'canplaythrough']); + }, tagName + '.autoplay and internal pause steps'); +} + +autoplay_test('audio', getAudioURI('/media/sound_5')); +autoplay_test('video', getVideoURI('/media/movie_5')); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_canplay.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_canplay.html new file mode 100644 index 000000000..09ad89f8b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_canplay.html @@ -0,0 +1,44 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - readyState property during canplay</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("audio.readyState should be >= HAVE_FUTURE_DATA during canplay event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("canplay", function() { + t.step(function() { + assert_greater_than_equal(a.readyState, a.HAVE_FUTURE_DATA); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - readyState property during canplay"); + +test(function() { + var t = async_test("video.readyState should be >= HAVE_FUTURE_DATA during canplay event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("canplay", function() { + t.step(function() { + assert_greater_than_equal(v.readyState, v.HAVE_FUTURE_DATA); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - readyState property during canplay"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_canplaythrough.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_canplaythrough.html new file mode 100644 index 000000000..7ef7b5f74 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_canplaythrough.html @@ -0,0 +1,46 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - readyState property during canplaythrough</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("audio.readyState should be HAVE_ENOUGH_DATA during canplaythrough event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("canplaythrough", function() { + t.step(function() { + assert_equals(a.readyState, + a.HAVE_ENOUGH_DATA); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - readyState property during canplaythrough"); + +test(function() { + var t = async_test("video.readyState should be HAVE_ENOUGH_DATA during canplaythrough event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("canplaythrough", function() { + t.step(function() { + assert_equals(v.readyState, + v.HAVE_ENOUGH_DATA); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - readyState property during canplaythrough"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_loadeddata.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_loadeddata.html new file mode 100644 index 000000000..1de85eb86 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_loadeddata.html @@ -0,0 +1,44 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - readyState property during loadeddata</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("audio.readyState should be >= HAVE_CURRENT_DATA during loadeddata event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadeddata", function() { + t.step(function() { + assert_greater_than_equal(a.readyState, a.HAVE_CURRENT_DATA); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - readyState property during loadeddata"); + +test(function() { + var t = async_test("video.readyState should be >= HAVE_CURRENT_DATA during loadeddata event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("loadeddata", function() { + t.step(function() { + assert_greater_than_equal(v.readyState, v.HAVE_CURRENT_DATA); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - readyState property during loadeddata"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_loadedmetadata.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_loadedmetadata.html new file mode 100644 index 000000000..85db8afb7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_loadedmetadata.html @@ -0,0 +1,44 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - readyState property during loadedmetadata</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("audio.readyState should be >= HAVE_METADATA during loadedmetadata event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("loadedmetadata", function() { + t.step(function() { + assert_greater_than_equal(a.readyState, a.HAVE_METADATA); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - readyState property during loadedmetadata"); + +test(function() { + var t = async_test("video.readyState should be >= HAVE_METADATA during loadedmetadata event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("loadedmetadata", function() { + t.step(function() { + assert_greater_than_equal(v.readyState, v.HAVE_METADATA); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - readyState property during loadedmetadata"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_playing.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_playing.html new file mode 100644 index 000000000..92a1b7f50 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_during_playing.html @@ -0,0 +1,44 @@ +<!doctype html> +<html> + <head> + <title>{audio,video} events - readyState property during playing</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> + <audio id="a" autoplay controls> + </audio> + <video id="v" autoplay controls> + </video> + <div id="log"></div> + <script> +test(function() { + var t = async_test("audio.readyState should be >= HAVE_FUTURE_DATA during playing event", {timeout:5000}); + var a = document.getElementById("a"); + a.addEventListener("playing", function() { + t.step(function() { + assert_greater_than_equal(a.readyState, a.HAVE_FUTURE_DATA); + }); + t.done(); + a.pause(); + }, false); + a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); +}, "audio events - readyState property during playing"); + +test(function() { + var t = async_test("video.readyState should be >= HAVE_FUTURE_DATA during playing event", {timeout:5000}); + var v = document.getElementById("v"); + v.addEventListener("playing", function() { + t.step(function() { + assert_greater_than_equal(v.readyState, v.HAVE_FUTURE_DATA); + }); + t.done(); + v.pause(); + }, false); + v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); +}, "video events - readyState property during playing"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_initial.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_initial.html new file mode 100644 index 000000000..e9c112bd2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/readyState_initial.html @@ -0,0 +1,33 @@ +<!doctype html> +<html> + <head> + <title>{audio,video}.readyState - default state</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#dom-media-networkstate">spec reference</a></p> + <audio id="a"> + </audio> + <video id="v"> + </video> + <div id="log"></div> + <script> +test(function() { + var a = document.getElementById("a"); + assert_equals( + a.readyState, + a.HAVE_NOTHING, + "audioElement.readyState should be HAVE_NOTHING to begin with"); +}, "audio.readyState - default state"); + +test(function() { + var v = document.getElementById("v"); + assert_equals( + v.readyState, + v.HAVE_NOTHING, + "videoElement.readyState should be HAVE_NOTHING to begin with"); +}, "video.readyState - default state"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-currentTime.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-currentTime.html new file mode 100644 index 000000000..3d577dac9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-currentTime.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>seek to currentTime</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var v = document.createElement('video'); + v.src = getVideoURI('/media/movie_5'); + v.onloadedmetadata = t.step_func(function() { + assert_greater_than(v.readyState, v.HAVE_NOTHING, 'readyState'); + assert_greater_than(v.seekable.length, 0, 'seekable ranges'); + assert_false(v.seeking, 'seeking before setting currentTime'); + v.currentTime = v.currentTime; + assert_true(v.seeking, 'seeking after setting currentTime'); + var events = []; + v.onseeking = v.ontimeupdate = v.onseeked = t.step_func(function(e) { + events.push(e.type); + // v.seeking can be true or false in the seeking event, see + // https://www.w3.org/Bugs/Public/show_bug.cgi?id=24774 + if (e.type != 'seeking') { + assert_equals(v.seeking, false, 'seeking in ' + e.type + ' event'); + } + if (e.type == 'seeked') { + assert_array_equals(events, ['seeking', 'timeupdate', 'seeked'], + 'fired events'); + t.done(); + } + }); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-max-value.htm b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-max-value.htm new file mode 100644 index 000000000..a31f6c07a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-max-value.htm @@ -0,0 +1,23 @@ +<!doctype html> +<title>seek to Number.MAX_VALUE</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var v = document.createElement('video'); + v.src = getVideoURI('/media/movie_5'); + v.onloadedmetadata = t.step_func(function() { + assert_equals(v.seekable.length, 1); + v.currentTime = Number.MAX_VALUE; + assert_true(v.seeking, 'seeking after setting'); + assert_equals(v.currentTime, v.seekable.end(0), 'currentTime after setting'); + v.onseeked = t.step_func(function(e) { + assert_false(v.seeking, 'seeking in seeked event'); + assert_equals(v.currentTime, v.seekable.end(0), 'currentTime in seeked event'); + t.done(); + }); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time.htm b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time.htm new file mode 100644 index 000000000..56a99028d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time.htm @@ -0,0 +1,23 @@ +<!doctype html> +<title>seek to negative time</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var v = document.createElement('video'); + v.src = getVideoURI('/media/movie_5'); + v.onloadedmetadata = t.step_func(function() { + assert_equals(v.seekable.start(0), 0, 'earliest seekable time'); + v.currentTime = -1; + assert_true(v.seeking, 'seeking after setting'); + assert_equals(v.currentTime, 0, 'currentTime after setting'); + v.onseeked = t.step_func(function(e) { + assert_false(v.seeking, 'seeking in seeked event'); + assert_equals(v.currentTime, 0, 'currentTime in seeked event'); + t.done(); + }); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/src_reflects_attribute_not_source_elements.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/src_reflects_attribute_not_source_elements.html new file mode 100644 index 000000000..3dd43cc3f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/src_reflects_attribute_not_source_elements.html @@ -0,0 +1,33 @@ +<!doctype html> +<html> + <head> + <title>{audio,video}.src - reflection test</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <p><a href="https://html.spec.whatwg.org/multipage/#dom-media-src">spec reference</a></p> + <audio id="audio" src="foo"> + <source src="barbaz" /> + </audio> + <video id="video" src="foo"> + <source src="barbaz" /> + </video> + <div id="log"></div> + <script> +test(function() { + assert_equals( + document.getElementById("audio").src.indexOf("barbaz"), + -1, + "audioElement.src should reflect src attribute, not source child elements"); +}, "audio.src - reflection test"); + +test(function() { + assert_equals( + document.getElementById("video").src.indexOf("barbaz"), + -1, + "videoElement.src should reflect src attribute, not source child elements"); +}, "video.src - reflection test"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cloneNode.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cloneNode.html new file mode 100644 index 000000000..1159a52ff --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cloneNode.html @@ -0,0 +1,86 @@ +<!doctype html> +<title>track element cloneNode</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var elm = document.createElement('track'); + assert_equals(elm.readyState, elm.NONE, 'elm.readyState after element creation'); + var clone = elm.cloneNode(true); + assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation'); + assert_not_equals(clone.track, elm.track, 'clone.track and elm.track'); +}, document.title+', not loaded'); + +async_test(function(t) { + var elm = document.createElement('track'); + var video = document.createElement('video'); + video.appendChild(elm); + elm.track.mode = 'showing'; + assert_equals(elm.readyState, elm.NONE, 'elm.readyState after appening to video setting mode'); + elm.src = 'resources/track.vtt?pipe=trickle(d1)'; + assert_equals(elm.readyState, elm.NONE, 'elm.readyState after setting src'); + setTimeout(t.step_func_done(function() { + assert_equals(elm.readyState, elm.LOADING, 'elm.readyState in setTimeout'); + var clone = elm.cloneNode(true); + assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation'); + video.appendChild(clone); + clone.track.mode = 'showing'; + assert_equals(clone.readyState, clone.NONE, 'clone.readyState after appending to video and setting mode'); + assert_not_equals(clone.track, elm.track, 'clone.track and elm.track'); + }), 0); +}, document.title+', loading'); + +async_test(function(t) { + var elm = document.createElement('track'); + var video = document.createElement('video'); + video.appendChild(elm); + elm.track.mode = 'showing'; + elm.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:01.000\nfoo'); + assert_equals(elm.readyState, elm.NONE, 'elm.readyState after setting src'); + elm.onload = this.step_func(function() { + assert_equals(elm.readyState, elm.LOADED, 'elm.readyState'); + assert_equals(elm.track.cues.length, 1, 'elm.track.cues.length'); + assert_equals(elm.track.cues[0].startTime, 0, 'elm.track.cues[0].startTime'); + assert_equals(elm.track.cues[0].endTime, 1, 'elm.track.cues[0].endTime'); + assert_equals(elm.track.cues[0].text, 'foo', 'elm.track.cues[0].text'); + var clone = elm.cloneNode(true); + assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation'); + video.appendChild(clone); + clone.track.mode = 'showing'; + assert_equals(clone.readyState, clone.NONE, 'clone.readyState after appending to video and setting mode'); + assert_not_equals(clone.track, elm.track, 'clone.track and elm.track'); + clone.onload = this.step_func(function(){ + assert_equals(clone.readyState, clone.LOADED, 'clone.readyState'); + assert_not_equals(clone.track, elm.track, 'clone.track and elm.track'); + assert_not_equals(clone.track.cues, elm.track.cues, 'clone.track.cues and elm.track.cues'); + assert_equals(clone.track.cues.length, 1, 'clone.track.cues.length'); + assert_not_equals(clone.track.cues[0], elm.track.cues[0], 'cues[0]'); + assert_equals(clone.track.cues[0].startTime, 0, 'clone.track.cues[0].startTime'); + assert_equals(clone.track.cues[0].endTime, 1, 'clone.track.cues[0].endTime'); + assert_equals(clone.track.cues[0].text, 'foo', 'clone.track.cues[0].text'); + this.done(); + }); + clone.onerror = this.step_func(function() { assert_unreached('clone got error'); }); + }); + elm.onerror = this.step_func(function() { assert_unreached('elm got error'); }); +}, document.title+', loaded'); + +async_test(function(t) { + var elm = document.createElement('track'); + var video = document.createElement('video'); + video.appendChild(elm); + elm.track.mode = 'showing'; + elm.onerror = t.step_func(function() { + assert_equals(elm.readyState, elm.ERROR, 'elm.readyState in onerror'); + var clone = elm.cloneNode(true); + assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation'); + video.appendChild(clone); + clone.track.mode = 'showing'; + assert_equals(clone.readyState, clone.NONE, 'clone.readyState after appending to video and setting mode'); + assert_not_equals(clone.track, elm.track, 'clone.track and elm.track'); + clone.onerror = t.step_func_done(); + }); + elm.src = 'javascript:"network error"'; +}, document.title+', failed to load'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/003.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/003.html new file mode 100644 index 000000000..4236df29b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/003.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: No CORS, same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/004.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/004.html new file mode 100644 index 000000000..4f86d011a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/004.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: No CORS, same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/005.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/005.html new file mode 100644 index 000000000..e6a693400 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/005.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/006.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/006.html new file mode 100644 index 000000000..351b97d67 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/006.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/007.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/007.html new file mode 100644 index 000000000..4ccc6b66a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/007.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/008.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/008.html new file mode 100644 index 000000000..0444a8308 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/008.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/009.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/009.html new file mode 100644 index 000000000..dd6223275 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/009.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: No CORS, not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/010.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/010.html new file mode 100644 index 000000000..d75d6f4d6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/010.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/011.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/011.html new file mode 100644 index 000000000..6d0fae6de --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/011.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/012.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/012.html new file mode 100644 index 000000000..110497b49 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/012.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/013.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/013.html new file mode 100644 index 000000000..d2a9ddb19 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/013.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/014.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/014.html new file mode 100644 index 000000000..a1d6a8b29 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/014.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: No CORS, same-origin, no headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/015.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/015.html new file mode 100644 index 000000000..2850a24e1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/015.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: No CORS, same-origin, with headers, redirects to same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/016.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/016.html new file mode 100644 index 000000000..5cd5a85d4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/016.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/017.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/017.html new file mode 100644 index 000000000..0ec5bc329 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/017.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers, redirects to same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/018.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/018.html new file mode 100644 index 000000000..f639d043a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/018.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, no headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/019.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/019.html new file mode 100644 index 000000000..45e1291c9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/019.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, with headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/020.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/020.html new file mode 100644 index 000000000..e1153b681 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/020.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, no headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'no'}]}; // redirect not followed +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/021.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/021.html new file mode 100644 index 000000000..ec2e9d8bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/021.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, with headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'no'}, {cors:'null', cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/022.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/022.html new file mode 100644 index 000000000..e8fb0c3d4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/022.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, with headers, redirects to same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:origin, cookie:'no'}, {cors:'null', cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/023.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/023.html new file mode 100644 index 000000000..ac9bb3546 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/023.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, no headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'yes'}]}; // redirect not followed +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/024.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/024.html new file mode 100644 index 000000000..302340022 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/024.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, with headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'yes'}, {cors:'null', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/025.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/025.html new file mode 100644 index 000000000..5cbe8528e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/025.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, with headers, redirects to same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:origin, cookie:'yes'}, {cors:'null', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/026.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/026.html new file mode 100644 index 000000000..c8386ffff --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/026.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: No CORS, same-origin, with headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}]}; // redirect not followed +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/027.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/027.html new file mode 100644 index 000000000..5fe4760e6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/027.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers, redirects to not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/028.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/028.html new file mode 100644 index 000000000..6019d37b6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/028.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, with headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/029.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/029.html new file mode 100644 index 000000000..7fa85456d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/029.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, no headers, redirects to not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/030.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/030.html new file mode 100644 index 000000000..f7abf3b1e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/030.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, with headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/031.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/031.html new file mode 100644 index 000000000..d709d0bc4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/031.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, no headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'no'}]}; // redirect not followed +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/032.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/032.html new file mode 100644 index 000000000..62b1008a4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/032.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, with headers, redirects to not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'no'}, {cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/033.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/033.html new file mode 100644 index 000000000..215cae241 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/033.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, not same-origin, with headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:origin, cookie:'no'}, {cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/034.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/034.html new file mode 100644 index 000000000..bebb43ba8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/034.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, no headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'yes'}]}; // redirect not followed +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/035.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/035.html new file mode 100644 index 000000000..a17fb7dfc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/035.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, with headers, redirects to not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:origin, cookie:'yes'}, {cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/036.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/036.html new file mode 100644 index 000000000..52411177e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/036.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, not same-origin, with headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:origin, cookie:'yes'}, {cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/037.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/037.html new file mode 100644 index 000000000..675b913a1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/037.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers, redirects to not same-origin, no headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'no'}]}; // second redirect not followed +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/038.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/038.html new file mode 100644 index 000000000..a29b2bdea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/038.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, with headers, redirects to not same-origin, with headers, redirects to same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'no'}, {cors:'null', cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/039.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/039.html new file mode 100644 index 000000000..fcd4871dd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/039.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers, redirects to not same-origin, with headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'no'}, {cors:'null', cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/040.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/040.html new file mode 100644 index 000000000..3c819684c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/040.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, no headers, redirects to not same-origin, no headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'yes'}]}; // second redirect not followed +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/041.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/041.html new file mode 100644 index 000000000..f0f81953f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/041.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, with headers, redirects to not same-origin, with headers, redirects to same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'yes'}, {cors:'null', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/042.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/042.html new file mode 100644 index 000000000..c1ffa5f1e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/042.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, no headers, redirects to not same-origin, with headers, redirects to same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:origin, cookie:'yes'}, {cors:'null', cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/043.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/043.html new file mode 100644 index 000000000..09072a989 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/043.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers, redirects to same-origin, no headers, redirects to not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}, {cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/044.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/044.html new file mode 100644 index 000000000..0d4a9fefb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/044.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Anonymous, same-origin, no headers, redirects to same-origin, no headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}, {cors:origin, cookie:'no'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/045.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/045.html new file mode 100644 index 000000000..7151364f9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/045.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, no headers, redirects to same-origin, no headers, redirects to not same-origin, no headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'error', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}, {cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/046.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/046.html new file mode 100644 index 000000000..e28646281 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/046.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>track CORS: Use Credentials, same-origin, no headers, redirects to same-origin, no headers, redirects to not same-origin, with headers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script src=/common/utils.js></script> +<script src=support/common.js?pipe=sub></script> +<script> +var expected = {event:'load', requests:[{cors:'no', cookie:'yes'}, {cors:'no', cookie:'yes'}, {cors:origin, cookie:'yes'}]}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/common.js b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/common.js new file mode 100644 index 000000000..9d48abde0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/common.js @@ -0,0 +1,144 @@ +setup(function(){ + window.id = token(); + var p = document.createElement('p'); + p.innerHTML = 'Test id: <samp>'+id+'</samp>'; + document.body.appendChild(p); + window.actual = {event:null, requests:[]}; + window.errors = []; + window.origin = location.protocol+'//'+location.host; + window.escapedOrigin = encodeURIComponent(origin); + window.sameOriginURL = "http://{{domains[]}}:{{ports[http][0]}}" + location.pathname.replace(/\/[^\/]+$/, '/'); + window.otherOriginURL = "http://{{domains[www1]}}:{{ports[http][0]}}" + location.pathname.replace(/\/[^\/]+$/, '/'); +}, {timeout:10000, explicit_done:true}); + +onload = function() { + (async_test(document.title, {timeout:10000})).step(function() { + // fail early if track isn't supported + assert_true('HTMLTrackElement' in window, 'track not supported'); + window.corsMode = document.title.match(/^track CORS: (No CORS|Anonymous|Use Credentials)/)[1]; + var requests_tmp = document.title.substr(('track CORS: '+corsMode+', ').length).split(/, redirects to /g); + window.requests = []; + requests_tmp.forEach(function(r) { + var parts = r.split(', '); + requests.push({sameOrigin:parts[0] == 'same-origin', withHeaders:parts[1] == 'with headers'}); + }); + if (document.title.indexOf('not same-origin') > -1) { + window.hasCrossDomainCookie = true; + this.step(setCrossDomainCookie); + } else { + window.hasCrossDomainCookie = false; + this.step(loadTrack); + } + }); + done(); +}; + +function setCrossDomainCookie() { + var iframe = document.createElement('iframe'); + iframe.onload = this.step_func(loadTrack); + iframe.src = otherOriginURL + 'support/set-cookie.html#'+id; + document.body.appendChild(iframe); +} + +function loadTrack() { + var video = document.createElement('video'); + window.track = document.createElement('track'); + if (corsMode == 'Anonymous') + video.setAttribute('crossorigin', 'anonymous'); + else if (corsMode == 'Use Credentials') + video.setAttribute('crossorigin', 'use-credentials'); + // else No CORS, omit the crossorigin attribute + video.appendChild(track); + document.body.appendChild(video); + track.track.mode = 'showing'; + document.cookie = id+'=yes;path=/;max-age=10'; + var url = ''; + var r; + while (r = requests.pop()) { + url = (r.sameOrigin ? sameOriginURL : otherOriginURL) + + 'support/cors-tester.py?id=' + id + + (r.withHeaders ? '&origin=' + escapedOrigin : '') + + (url === '' ? '' : '&redirect=' + encodeURIComponent(url)); + } + track.src = url; + track.onerror = track.onload = this.step_func(function(e) { + actual.event = e.type; + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'support/cors-tester.py?read=true&id=' + id, true); + xhr.onload = this.step_func(function() { + if (xhr.status == 200) { + var lines = xhr.responseText.split('\n'); + lines.forEach(function(line) { + var chunks = line.split(' | '); + var current = {}; + actual.requests.push(current); + chunks.forEach(function(chunk) { + var nameval = chunk.split(' = '); + var name = nameval[0]; + var value = nameval[1]; + current[name] = value; + }); + }); + } else if (xhr.status == 404) { + //No stash was found + } else { + errors.push('got unexpected xhr status: '+xhr.status); + } + this.step(removeCookies); + }); + xhr.onerror = this.step_func(function() { + errors.push('got xhr error'); + this.step(removeCookies); + }); + xhr.send(); + }); +} + +function removeCookies() { + document.cookie = id+'=;path=/;max-age=0'; + var nextStep = checkData; + if (hasCrossDomainCookie) { + var iframe = document.createElement('iframe'); + iframe.onload = this.step_func(nextStep); + iframe.src = otherOriginURL + 'support/cors-tester.py?delete-cookie&id=' + id; + document.body.appendChild(iframe); + } else { + this.step(nextStep); + } +} + +function removeLog() { + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'support/cors-tester.py?cleanup&id='+id, true); + xhr.onload = this.step_func(function() { + assert_equals(xhr.responseText, 'OK', 'failed to clean up log: '+id); + this.step(checkData); + }); + xhr.onerror = this.step_func(function() { + assert_unreached('failed to clean up log: '+id); + }); + xhr.send(); +} + +function checkData() { + assert_equals(errors.length, 0, errors); + try { + if (actual.event == 'load' && expected.event == 'error') + assert_unreached('Security problem: got load event but expected error event'); + assert_object_equals(actual, expected); + } catch(ex) { + var style = document.createElement('style'); + style.textContent = '.json-diffs td { vertical-align:top } .json-diffs pre { margin:0 }'; + document.head.appendChild(style); + var table = document.createElement('table'); + table.border = ""; + table.className = 'json-diffs'; + table.innerHTML = '<tr><th>Actual<th>Expected<tr><td><pre></pre><td><pre></pre>'; + table.getElementsByTagName('pre')[0].textContent = JSON.stringify(actual, null, 2); + table.getElementsByTagName('pre')[1].textContent = JSON.stringify(expected, null, 2); + document.body.insertBefore(table, document.getElementById('log')); + throw ex; + } + assert_equals(track.track.cues.length, expected.event == 'load' ? 1 : 0, 'track.track.cues.length'); + this.done(); +} diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/cors-tester.py b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/cors-tester.py new file mode 100644 index 000000000..1c27a0d14 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/cors-tester.py @@ -0,0 +1,51 @@ +from wptserve.handlers import HTTPException +import urllib + +def main(request, response): + if request.method != "GET": + raise HTTPException(400, message="Method was not GET") + + if not "id" in request.GET: + raise HTTPException(400, message="No id") + + id = request.GET['id'] + + if "read" in request.GET: + data = request.server.stash.take(id) + if data is None: + response.set_error(404, "Tried to read data not yet set") + return + return [("Content-Type", "text/plain")], data + + elif "cleanup" in request.GET: + request.server.stash.take(id) + return "OK" + + elif "delete-cookie" in request.GET: + response.delete_cookie(id) + return [("Content-Type", "text/plain")], "OK" + + if "origin" in request.GET: + response.headers.set('Access-Control-Allow-Origin', request.GET['origin']) + response.headers.set('Access-Control-Allow-Credentials', 'true') + + cors = request.headers.get("origin", "no") + + cookie = request.cookies.first(id, "no") + + line = 'cors = ' + cors + ' | cookie = ' + cookie.value; + + data = request.server.stash.take(id) + if data is not None: + line = data + "\n" + line + + request.server.stash.put(id, line) + + if "redirect" in request.GET: + response.status = 302 + response.headers.set('Location', request.GET['redirect']) + else: + return """WEBVTT + +00:00:00.000 --> 00:00:10.000 +Test""" diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/remove-cookie.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/remove-cookie.html new file mode 100644 index 000000000..00430e3f0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/remove-cookie.html @@ -0,0 +1,6 @@ +<!doctype html> +<title>Remove cookie from location.hash</title> +<script> +if (location.hash) + document.cookie = decodeURIComponent(location.hash.substr(1))+'=yes;path=/;max-age=0'; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/set-cookie.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/set-cookie.html new file mode 100644 index 000000000..cc1c92638 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/cors/support/set-cookie.html @@ -0,0 +1,6 @@ +<!doctype html> +<title>Set cookie from location.hash</title> +<script> +if (location.hash) + document.cookie = decodeURIComponent(location.hash.substr(1))+'=yes;path=/;max-age=15'; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.de.vtt b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.de.vtt new file mode 100644 index 000000000..9eaf3d31e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.de.vtt @@ -0,0 +1,4 @@ +WEBVTT + +00:00:00.000 --> 00:00:01.000 +German diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.en.vtt b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.en.vtt new file mode 100644 index 000000000..4241f35b5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.en.vtt @@ -0,0 +1,4 @@ +WEBVTT + +00:00:00.000 --> 00:00:01.000 +English diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.fr.vtt b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.fr.vtt new file mode 100644 index 000000000..5523224e0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.fr.vtt @@ -0,0 +1,4 @@ +WEBVTT + +00:00:00.000 --> 00:00:01.000 +french diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.vtt b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.vtt new file mode 100644 index 000000000..c916c0983 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/resources/track.vtt @@ -0,0 +1,4 @@ +WEBVTT + +00:00:00.000 --> 00:00:01.000 +test diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/src-clear-cues.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/src-clear-cues.html new file mode 100644 index 000000000..3ba8c9db8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/src-clear-cues.html @@ -0,0 +1,52 @@ +<!doctype html> +<title>track element changing "track URL" and clearing cues</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +(async_test(document.title+', set mode, add cue, set src')).step(function(){ + var track = document.createElement('track'); + var c = new VTTCue(0, 1, 'foo'); + c.id = 'id'; + track.track.addCue(c); + assert_equals(track.track.cues, null, 'cues before setting src or mode'); + track.track.mode = 'showing'; + assert_equals(track.track.cues.length, 1, 'cues after setting mode'); + var cues = track.track.cues; + track.src = 'data:,a'; + assert_equals(track.track.cues.length, 0, 'cues.length after setting src'); + assert_equals(track.track.cues, cues, 'track.track.cues sameness after setting src'); + assert_equals(c.id, 'id', 'liveness of removed cue'); + this.done(); +}); + +(async_test(document.title+', set mode, set src, add cue, change src')).step(function(){ + var track = document.createElement('track'); + track.track.mode = 'showing'; + track.src = 'data:,a'; + var c = new VTTCue(0, 1, 'foo'); + c.id = 'id'; + track.track.addCue(c); + assert_equals(track.track.cues.length, 1, 'cues.length before changing src'); + var cues = track.track.cues; + track.src = 'data:,b'; + assert_equals(track.track.cues.length, 0, 'cues.length after changing src'); + assert_equals(track.track.cues, cues, 'track.track.cues sameness after changing src'); + assert_equals(c.id, 'id', 'liveness of removed cue'); + this.done(); +}); + +(async_test(document.title+', set mode, add cue, change mode to disabled, set src')).step(function(){ + var track = document.createElement('track'); + track.track.mode = 'showing'; + var c = new VTTCue(0, 1, 'foo'); + c.id = 'id'; + track.track.addCue(c); + var cues = track.track.cues; + track.track.mode = 'disabled'; + track.src = 'data:,a'; + assert_equals(cues.length, 0, 'cues.length after changing src'); + assert_equals(c.id, 'id', 'liveness of removed cue'); + this.done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-api-texttracks.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-api-texttracks.html new file mode 100644 index 000000000..b2840d235 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-api-texttracks.html @@ -0,0 +1,36 @@ +<!DOCTYPE HTML> +<html> +<head> +<title>Track element - text tracks API test</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#text-track-api"> +<link rel="author" title="Hyunjin Cho"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<h1>Track element and API Test</h1> +<div style="display:none;"> + <video id="tracktest" src="/media/movie_300.mp4"> + <track kind="subtitles" src="resources/track.en.vtt" srclang="en" label="English"> + <track kind="captions" src="resources/track.en.vtt" srclang="en" label="English with Captions"> + <track id="french" kind="subtitles" src="resources/track.fr.vtt" srclang="fr" label="Francais"> + <track kind="subtitles" src="resources/track.de.vtt" srclang="de" label="Deutsch"> + </video> +</div> +<div id="log"></div> +<script> +test(function() { + var t1 = document.getElementById('tracktest').textTracks; + assert_not_equals(t1, undefined, "textTracks member should not be undefined"); +}, "Check the track elements"); +test(function() { + var t2 = document.getElementById('tracktest').textTracks.getTrackById("french"); + assert_not_equals(t2, undefined, "textTracks member should not be undefined"); +}, "Check getTrackById method"); +test(function() { + var t3 = document.getElementById('tracktest').textTracks.length; + assert_equals(t3, 4, "textTracks List should be 4"); +}, "Count track list"); +</script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/user-interface/muted.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/user-interface/muted.html new file mode 100644 index 000000000..906350d88 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/user-interface/muted.html @@ -0,0 +1,152 @@ +<!doctype html> +<title>muted</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/media.js"></script> +<style>video { display: none; }</style> +<div id=log></div> + +<script> +function test_setting(e, muted, hasAttribute) { + assert_equals(e.muted, muted); + assert_equals(e.hasAttribute('muted'), hasAttribute); + + e.muted = !e.muted; + assert_equals(e.muted, !muted); + assert_equals(e.hasAttribute('muted'), hasAttribute); + + e.muted = !e.muted; + assert_equals(e.muted, muted); + assert_equals(e.hasAttribute('muted'), hasAttribute); +} +</script> + +<!-- These tests are inside <audio>/<video> so that the steps for updating the + muted IDL attribute cannot be delayed until the end tag is parsed. --> + +<audio id=a1> +<script> +var a1 = document.getElementById('a1'); + +test(function() { + assert_false(a1.muted); +}, 'getting audio.muted (parser-created)'); + +test(function() { + test_setting(a1, false, false); +}, 'setting audio.muted (parser-created)'); +</script> +</audio> + +<audio id=a2 muted> +<script> +var a2 = document.getElementById('a2'); + +test(function() { + assert_true(a2.muted); +}, 'getting audio.muted with muted="" (parser-created)'); + +test(function() { + test_setting(a2, true, true); +}, 'setting audio.muted with muted="" (parser-created)'); +</script> +</audio> + +<video id=v1> +<script> +var v1 = document.getElementById('v1'); + +test(function() { + assert_false(v1.muted); +}, 'getting video.muted (parser-created)'); + +test(function() { + test_setting(v1, false, false); +}, 'setting video.muted (parser-created)'); +</script> +</video> + +<video id=v2 muted> +<script> +var v2 = document.getElementById('v2'); + +test(function() { + assert_true(v2.muted); +}, 'getting video.muted with muted="" (parser-created)'); + +test(function() { + test_setting(v2, true, true); +}, 'setting video.muted with muted="" (parser-created)'); +</script> +</video> + +<!-- Negative test to ensure that the load algorithm does not update the + muted IDL attribute to match the content attribute. --> + +<video id=v3 muted></video> +<script> +async_test(function(t) { + var v = document.getElementById('v3'); + assert_true(v.muted); + v.muted = false; + v.src = 'data:,'; // invokes load() + v.addEventListener('error', t.step_func(function() { + assert_false(v.muted); + t.done(); + })); +}, 'getting video.muted with muted="" after load (parser-created)'); +</script> + +<script> +['audio', 'video'].forEach(function(tagName) { + test(function() { + var m = document.createElement(tagName); + assert_false(m.muted); + }, 'getting ' + tagName + '.muted (script-created)'); + + test(function() { + var m = document.createElement(tagName); + test_setting(m, false, false); + }, 'setting ' + tagName + '.muted (script-created)'); + + test(function() { + var m = document.createElement(tagName); + m.setAttribute('muted', ''); + assert_false(m.muted); + }, 'getting ' + tagName + '.muted with muted="" (script-created)'); + + test(function() { + var m = document.createElement(tagName); + m.setAttribute('muted', ''); + test_setting(m, false, true); + }, 'setting ' + tagName + '.muted with muted="" (script-created)'); + + // Spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=25153 + /* + test(function() { + var m = document.createElement(tagName); + m.setAttribute('muted', ''); + m = m.cloneNode(false); + assert_true(m.hasAttribute('muted')); + assert_false(m.muted); + }, 'getting ' + tagName + '.muted with muted="" (cloneNode-created)'); + */ + + test(function() { + var div = document.createElement('div'); + div.innerHTML = '<' + tagName + ' muted>'; + m = div.firstChild; + assert_true(m.hasAttribute('muted')); + assert_true(m.muted); + }, 'getting ' + tagName + '.muted with muted="" (innerHTML-created)'); + + test(function() { + var id = tagName; + assert_equals(document.getElementById(id), null); + document.write('<' + tagName + ' id=' + id + ' muted>'); + m = document.getElementById(id); + assert_true(m.hasAttribute('muted')); + assert_true(m.muted); + }, 'getting ' + tagName + '.muted with muted="" (document.write-created)'); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_008.htm b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_008.htm new file mode 100644 index 000000000..dff49d824 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_008.htm @@ -0,0 +1,45 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>HTML5 Media Elements: 'media' attribute</title> + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://www.w3.org/TR/html5/video.html#the-source-element" /> + <meta name="assert" content="'media' attribute is 'all' by default." /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script type="text/javascript" src="/common/media.js"></script> + <script type="text/javascript"> + var videotest = async_test(); + + function do_play(event) + { + videotest.step(function() { + var vid = document.getElementById("video0"); + assert_true(vid.currentSrc.indexOf("movie_300") > 0); + }); + videotest.done(); + } + + </script> + </head> + <body> + <div id='log'></div> + + <video id="video0" autoplay onplay="do_play(event);"> + <script type="text/javascript"> + + document.write( + "<source media='not all' src='" + getVideoURI("/media/movie_300") + "'" + + " />" + ); + document.write( + "<source src='" + getVideoURI("/media/movie_5") + "'" + + " media='all' />" + ); + + </script> + Your browser does not support media elements. + </video> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_controls_present-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_controls_present-manual.html new file mode 100644 index 000000000..8e44951d7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_controls_present-manual.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> + <head> + <title>Video Test: video_controls_present.html</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-controls" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the controls attribute is present in the video element that expecting the user agent exposes a controller user interface" /> + </head> + <body> + <p>Test passes if a controller user interface appears below and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <video id="m" controls>The user agent doesn't support media element.</video> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_loop_base.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_loop_base.html new file mode 100644 index 000000000..348f1cdae --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_loop_base.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<html> + <head> + <title>Video Test: video_loop_base</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-loop" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if video.loop is set to true that expecting the seeking event is fired more than once" /> + <meta name=timeout content=long> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/media.js"></script> + </head> + <body> + <div id="log"></div> + <video id="m" controls>The user agent doesn't support media element.</video> + <script type="text/javascript"> + var media = document.getElementById("m"); + var name = document.getElementsByName("assert")[0].content; + var t = async_test(name); + var looped = false; + + function startTest() { + if (looped) { + t.step(function() { + assert_true(true, "looped"); + }); + t.done(); + media.pause(); + } + + looped = true; + } + + media.addEventListener("seeking", startTest, false); + media.loop = true; + media.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_muted_overriding_volume-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_muted_overriding_volume-manual.html new file mode 100644 index 000000000..6d770666c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_muted_overriding_volume-manual.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> + <head> + <title>Video Test: video_muted_overriding_volume</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-muted" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the muted attribute is present in the video element with volume is set to loudest that expecting the user hears no sound" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the video is playing without sound output and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <video id="m" controls muted>The user agent doesn't support media element.</video> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + media.volume = 1.0; + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_muted_present-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_muted_present-manual.html new file mode 100644 index 000000000..bc8082777 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_muted_present-manual.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> + <head> + <title>Video Test: video_muted_present</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-muted" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the muted attribute is present in the video element that expecting the user hears no sound" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the video is playing without sound output and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <video id="m" controls muted>The user agent doesn't support media element.</video> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_check.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_check.html new file mode 100644 index 000000000..1a45358a7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_check.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<html> + <head> + <title>Video Test: video_volume_check</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check that video.volume returns the value of the muted content attribute" /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id="log"></div> + <video id="m">The user agent doesn't support media element.</video> + <script type="text/javascript"> + var media = document.getElementById("m"); + var VOLUME = { + 'SILENT' : 0.0, + 'NORMAL' : 0.5, + 'LOUDEST' : 1.0, + 'LOWER' : -1.1, + 'UPPER' : 1.1, + }; + + test(function() { + assert_false(media.volume < VOLUME.SILENT || media.volume > VOLUME.LOUDEST, "media.volume outside the range 0.0 to 1.0 inclusive"); + }, "Check if the intial value of the video.volume is in the range 0.0 to 1.0 inclusive"); + + function volume_setting(vol, name) + { + if (vol < VOLUME.SILENT || vol > VOLUME.LOUDEST) { + try { + media.volume = vol; + test(function() { + assert_true(false, "media.volume setting exception"); + }, name); + } catch(e) { + test(function() { + // 1 should be e.IndexSizeError or e.INDEX_SIZE_ERR in previous spec + assert_equals(e.code, 1, "media.volume setting exception"); + }, name); + } + } else { + media.volume = vol; + test(function() { + assert_equals(media.volume, vol, "media.volume new value"); + }, name); + } + } + + volume_setting(VOLUME.NORMAL, "Check if video.volume is able to set to new value in the range 0.0 to 1.0"); + volume_setting(VOLUME.SILENT, "Check if media.volume is able to set to new value 0.0 as silent"); + volume_setting(VOLUME.LOUDEST, "Check if media.volume is able to set to new value 1.0 as loudest"); + volume_setting(VOLUME.LOWER, "Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown"); + volume_setting(VOLUME.UPPER, "Check if video.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_loudest-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_loudest-manual.html new file mode 100644 index 000000000..747578120 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_loudest-manual.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> + <head> + <title>Video Test: video_volume_loudest</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the volume attribute is set to 1.0 as loudest in the video element that expecting the user hears sound loudly" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the video is playing with sound heard and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <video id="m" controls>The user agent doesn't support media element.</video> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + media.volume = 1.0; + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_silent-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_silent-manual.html new file mode 100644 index 000000000..1768dd4d4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/video_volume_silent-manual.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> + <head> + <title>Video Test: video_volume_silent</title> + <link rel="author" title="Intel" href="http://www.intel.com" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" /> + <meta name="flags" content="" /> + <meta name="assert" content="Check if the volume attribute is set to 0.0 as silent in the video element that expecting the user hears no sound" /> + <script src="/common/media.js"></script> + </head> + <body> + <p>Test passes if the video is playing without sound heard and the text 'The user agent doesn't support media element.' does not appear anywhere on this page</p> + <video id="m" controls volume=0.0>The user agent doesn't support media element.</video> + <script type="text/javascript"> + var media = document.getElementById("m"); + media.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); + media.volume = 0.0; + media.play(); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/volume_nonfinite.html b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/volume_nonfinite.html new file mode 100644 index 000000000..6e90a2ebc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/volume_nonfinite.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Setting HTMLMediaElement.volume to non-finite numbers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +["audio", "video"].forEach(function(aElement) { + [NaN, Infinity, -Infinity].forEach(function(aValue) { + test(function() { + var el = document.createElement(aElement); + assert_throws(new TypeError(), function() { + el.volume = aValue; + }); + }, "Setting " + aElement + ".volume to " + String(aValue) + " should throw a TypeError"); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/svg/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/svg/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/svg/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-coords.html b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-coords.html new file mode 100644 index 000000000..9ec6f3e42 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-coords.html @@ -0,0 +1,47 @@ +<!doctype html> +<meta charset=utf-8> +<title>HTMLAreaElement coords parsing</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<style> + body { margin: 0 } +</style> +<img src=/images/threecolors.png usemap=#x id=img width=300 height=300> +<map name=x><area id=area></map> +<script src=support/hit-test.js></script> +<script> +tests = [ + {desc: 'COMMA', shape: 'rect', coords: "2,2,10,10", hit: hitRect}, + {desc: 'SEMICOLON', shape: 'rect', coords: "2;2;10;10", hit: hitRect}, + {desc: 'SPACE', shape: 'rect', coords: "2 2 10 10", hit: hitRect}, + {desc: 'TAB', shape: 'rect', coords: "2\t2\t10\t10", hit: hitRect}, + {desc: 'FORM FEED', shape: 'rect', coords: "2\f2\f10\f10", hit: hitRect}, + {desc: 'LINE FEED', shape: 'rect', coords: "2\n2\n10\n10", hit: hitRect}, + {desc: 'CARRIGAGE RETURN', shape: 'rect', coords: "2\r2\r10\r10", hit: hitRect}, + {desc: 'LINE TABULATION', shape: 'rect', coords: "2\u000b2\u000b10\u000b10", hit: hitNone}, + {desc: 'LINE NEXT', shape: 'rect', coords: "2\u00852\u008510\u008510", hit: hitNone}, + {desc: 'EN QUAD', shape: 'rect', coords: "2\u20002\u200010\u200010", hit: hitNone}, + {desc: 'abc between numbers', shape: 'rect', coords: "2a2b20c20,2,10,10", hit: hitRect}, + {desc: 'COLON between numbers', shape: 'rect', coords: "2:2:20:20,2,10,10", hit: hitRect}, + {desc: 'U+0000 between numbers', shape: 'rect', coords: "2\u00002\u000020\u000020,2,10,10", hit: hitRect}, + {desc: 'leading COMMA', shape: 'rect', coords: ",2,2,10,10", hit: hitRect}, + {desc: 'leading SPACE', shape: 'rect', coords: " 2,2,10,10", hit: hitRect}, + {desc: 'leading SEMICOLON', shape: 'rect', coords: ";2,2,10,10", hit: hitRect}, + {desc: 'trailing COMMA', shape: 'rect', coords: "2,2,10,", hit: hitNone}, + {desc: 'trailing SPACE', shape: 'rect', coords: "2,2,10 ", hit: hitNone}, + {desc: 'trailing SEMICOLON', shape: 'rect', coords: "2,2,10;", hit: hitNone}, + {desc: 'PERCENT', shape: 'rect', coords: "2%,2%,10%,10%", hit: hitRect}, + {desc: 'CSS units', shape: 'rect', coords: "2in,2in,10cm,10cm", hit: hitRect}, + {desc: 'float', shape: 'rect', coords: "1.4,1.4,10,10", hit: hitRect}, + {desc: 'number starting with PERIOD', shape: 'rect', coords: ".4,.4,10,10", hit: [[area, 1, 1], [img, 0, 0]]}, + {desc: 'sci-not', shape: 'rect', coords: "2,2,1e1,1e1", hit: hitRect}, + {desc: 'leading/trailing garbage', shape: 'rect', coords: "='2,2,10,10' ", hit: hitRect}, + {desc: 'non-ascii garbage', shape: 'rect', coords: "“2,2,10,10\"", hit: hitRect}, + {desc: 'URL garbage with number', shape: 'rect', coords: "2,2,10ls/spain/holidays/regions/10/Canary+Islands/Canary+Islands.html", hit: hitNone}, + {desc: 'consecutive COMMAs', shape: 'rect', coords: "2,,10,10", hit: hitNone}, + {desc: 'consecutive SPACEs', shape: 'rect', coords: "2 10,10", hit: hitNone}, + {desc: 'consecutive SEMICOLONs', shape: 'rect', coords: "2;;10,10", hit: hitNone}, + {desc: 'several consecutive separators', shape: 'rect', coords: ",,2;,;2,;,10 \t\r\n10;;", hit: hitRect}, + {desc: 'one too many numbers, trailing COMMA', shape: 'poly', coords: "100,100,120,100,100,120,300,", hit: hitPoly}, +]; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-processing.html b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-processing.html new file mode 100644 index 000000000..d1c3a83dd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-processing.html @@ -0,0 +1,32 @@ +<!doctype html> +<meta charset=utf-8> +<title>HTMLAreaElement processing</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<style> + body { margin: 0 } +</style> +<img src=/images/threecolors.png usemap=#x id=img width=300 height=300> +<map name=x><area id=area></map> +<script src=support/hit-test.js></script> +<script> +var tests = [ + {desc: 'too few numbers', shape: 'rect', coords: "2,2,10", hit: hitNone}, + {desc: 'negative', shape: 'rect', coords: "-10,-10,10,10", hit: [[area, 1, 1], [img, 299, 299]]}, + {desc: 'empty string', shape: 'rect', coords: "", hit: hitNone}, + {desc: 'omitted coords', shape: 'rect', coords: null, hit: hitNone}, + {desc: 'first > third', shape: 'rect', coords: "10,2,2,10", hit: hitRect}, + {desc: 'second > fourth', shape: 'rect', coords: "2,10,10,2", hit: hitRect}, + {desc: 'first > third, second > fourth', shape: 'rect', coords: "10,10,2,2", hit: hitRect}, + + {desc: 'negative', shape: 'default', coords: "-10,-10,-10,-10", hit: hitAll}, + + {desc: 'too few numbers', shape: 'circle', coords: "20,40", hit: hitNone}, + {desc: 'negative radius', shape: 'circle', coords: "20,40,-10", hit: hitNone}, + {desc: 'zero radius', shape: 'circle', coords: "20,40,0", hit: hitNone}, + + {desc: 'too few numbers', shape: 'poly', coords: "100,100,120,100,100", hit: hitNone}, + {desc: 'one too many numbers', shape: 'poly', coords: "100,100,120,100,100,120,300", hit: hitPoly}, + {desc: 'even-odd rule', shape: 'poly', coords: "100,100,200,100,100,200,150,50,200,200", hit: hitStar}, +]; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-shape.html b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-shape.html new file mode 100644 index 000000000..1ad0690f9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-shape.html @@ -0,0 +1,36 @@ +<!doctype html> +<meta charset=utf-8> +<title>HTMLAreaElement shape</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<style> + body { margin: 0 } +</style> +<img src=/images/threecolors.png usemap=#x id=img width=300 height=300> +<map name=x><area id=area></map> +<script src=support/hit-test.js></script> +<script> +var tests = [ + {desc: 'missing value default', shape: null, coords: "2,2,10,10", hit: hitRect}, + {desc: 'missing value default', shape: null, coords: "20,40,10", hit: hitNone}, + {desc: 'missing value default', shape: null, coords: null, hit: hitNone}, + {desc: 'invalid value default', shape: 'foobar invalid', coords: "2,2,10,10", hit: hitRect}, + {desc: 'invalid value default', shape: '', coords: "2,2,10,10", hit: hitRect}, + + {desc: 'empty string', shape: 'default', coords: "", hit: hitAll}, + {desc: 'omitted coords', shape: 'DEFAULT', coords: null, hit: hitAll}, + + {desc: 'simple', shape: 'rect', coords: "2,2,10,10", hit: hitRect}, + {desc: 'simple', shape: 'rectangle', coords: "2,2,10,10", hit: hitRect}, + + {desc: 'simple', shape: 'circle', coords: "20,40,10", hit: hitCircle}, + {desc: 'simple', shape: 'circ', coords: "20,40,10", hit: hitCircle}, + {desc: 'simple', shape: 'CIRCLE', coords: "20,40,10", hit: hitCircle}, + {desc: 'simple', shape: 'CIRC', coords: "20,40,10", hit: hitCircle}, + {desc: 'LATIN CAPITAL LETTER I WITH DOT ABOVE', shape: 'C\u0130RCLE', coords: "20,40,10", hit: hitNone}, + {desc: 'LATIN SMALL LETTER DOTLESS I', shape: 'c\u0131rcle', coords: "20,40,10", hit: hitNone}, + + {desc: 'simple', shape: 'poly', coords: "100,100,120,100,100,120", hit: hitPoly}, + {desc: 'simple', shape: 'polygon', coords: "100,100,120,100,100,120", hit: hitPoly}, +]; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-stringifier.html b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-stringifier.html new file mode 100644 index 000000000..d06429630 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/area-stringifier.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<title>HTMLAreaElement stringifier</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://heycam.github.io/webidl/#es-stringifier"> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=/common/stringifiers.js></script> +<div id=log></div> +<script> +test(function() { + test_stringifier_attribute(document.createElement("area"), "href", false); + var area = document.createElement("area"); + area.setAttribute("href", "foo"); + test_stringifier_attribute(area, "href", false); +}) +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/support/hit-test.js b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/support/hit-test.js new file mode 100644 index 000000000..54cda3e5c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-area-element/support/hit-test.js @@ -0,0 +1,42 @@ +setup({explicit_done: true}); + +var img = document.getElementById('img'); +var area = document.getElementById('area'); + +var hitRect = [[area, 3, 3], [area, 9, 9], [img, 1, 3], [img, 3, 1], [img, 11, 9], [img, 9, 11], [img, 21, 41], [img, 101, 101]]; +var hitNone = [[img, 3, 3], [img, 9, 9], [img, 1, 3], [img, 3, 1], [img, 11, 9], [img, 9, 11], [img, 21, 41], [img, 101, 101]]; +var hitAll = [[area, 1, 1], [area, 1, 299], [area, 299, 1], [area, 299, 299], [area, 21, 41], [area, 101, 101]]; +var hitCircle = [[area, 11, 40], [area, 29, 40], [area, 20, 31], [area, 20, 49], [img, 12, 32], [img, 28, 48], [img, 101, 101]]; +var hitPoly = [[area, 101, 101], [area, 119, 101], [area, 101, 119], [img, 118, 118], [img, 3, 3], [img, 21, 41]]; +var hitStar = [[area, 101, 101], [area, 199, 101], [area, 150, 51], [img, 150, 125], [img, 3, 3], [img, 21, 41]]; + +var tests; +// The test file should have `tests` defined as follows: +// tests = [ +// {desc: string, shape: string?, coords: string?, hit: [[element, x, y], ...]}, +// ... +// ]; + +onload = function() { + tests.forEach(function(t) { + test(function(t_obj) { + if (area.shape === null) { + area.removeAttribute('shape'); + } else { + area.shape = t.shape; + } + if (area.coords === null) { + area.removeAttribute('coords'); + } else { + area.coords = t.coords; + } + t.hit.forEach(function(arr) { + var expected = arr[0]; + var x = arr[1]; + var y = arr[2]; + assert_equals(document.elementFromPoint(x, y), expected, 'elementFromPoint('+x+', '+y+')'); + }); + }, t.desc + ': ' + format_value(t.coords) + ' (' + t.shape + ')'); + }); + done(); +}; diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_001.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_001.htm new file mode 100644 index 000000000..f455c6824 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_001.htm @@ -0,0 +1,18 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>HTML5 Media Elements: Content inside the 'audio' element is not shown to the user (image).</title> + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#audio" /> + <link rel="match" href="audio_content-ref.htm" /> + <meta name="assert" content="Content inside the 'audio' element is not shown to the user (image)." /> +</head> +<body> +<p>Test passes if there is no red.</p> +<div id='testcontent'> +<audio><img src="../../../../images/fail.gif" /></audio> + +</div> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_002.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_002.htm new file mode 100644 index 000000000..23b3ea188 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_002.htm @@ -0,0 +1,18 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>HTML5 Media Elements: Content inside the 'audio' element is not shown to the user.</title> + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#audio" /> + <link rel="match" href="audio_content-ref.htm" /> + <meta name="assert" content="Content inside the 'audio' element is not shown to the user." /> +</head> +<body> +<p>Test passes if there is no red.</p> +<div id='testcontent'> +<audio><span style="color: red;">FAIL</span></audio> + +</div> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_constructor.html b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_constructor.html new file mode 100644 index 000000000..242098869 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_constructor.html @@ -0,0 +1,50 @@ +<!doctype html> +<meta charset=utf-8> +<title>Audio constructor</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var throwingObject = { + toString: function() { throw Error() }, + valueOf: function() { throw Error() } + }; + var tests = [ + [function() { return new Audio() }, null, "No arguments"], + [function() { return new Audio("") }, "", "Empty string argument"], + [function() { return new Audio("src") }, "src", "Non-empty string argument"], + [function() { return new Audio(null) }, "null", "Null argument"], + [function() { return new Audio(undefined) }, null, "Undefined argument"], + [function() { return new Audio("", throwingObject) }, "", "Extra argument"], + ]; + tests.forEach(function(t) { + var fn = t[0], expectedSrc = t[1], description = t[2]; + test(function() { + var element = fn(); + assert_equals(element.localName, "audio"); + assert_equals(element.tagName, "AUDIO"); + assert_equals(element.namespaceURI, "http://www.w3.org/1999/xhtml"); + assert_equals(element.nodeType, Node.ELEMENT_NODE); + assert_equals(element.getAttribute("preload"), "auto"); + assert_equals(element.getAttribute("src"), expectedSrc); + assert_equals(element.ownerDocument, document); + }, description); + }); +}); +test(function() { + assert_throws(new TypeError(), function() { + Audio(); + }); +}, "Calling Audio should throw"); +test(function() { + assert_throws(new TypeError(), function() { + HTMLAudioElement(); + }); +}, "Calling HTMLAudioElement should throw"); +test(function() { + assert_throws(new TypeError(), function() { + new HTMLAudioElement(); + }); +}, "Constructing HTMLAudioElement should throw"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_content-ref.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_content-ref.htm new file mode 100644 index 000000000..ef5964496 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-audio-element/audio_content-ref.htm @@ -0,0 +1,13 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>HTML5 Media Elements: Content inside the 'audio' element is not shown to the user.</title> + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> +</head> +<body> +<p>Test passes if there is no red.</p> +<div id='testcontent'> +</div> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.readonly.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.readonly.html new file mode 100644 index 000000000..5e1c22d2d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.readonly.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.canvas.readonly</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.canvas.readonly</h1> +<p class="desc">CanvasRenderingContext2D.canvas is readonly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("CanvasRenderingContext2D.canvas is readonly"); +_addTest(function(canvas, ctx) { + +var c = document.createElement('canvas'); +var d = ctx.canvas; +_assertDifferent(c, d, "c", "d"); +ctx.canvas = c; +_assertSame(ctx.canvas, d, "ctx.canvas", "d"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.reference.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.reference.html new file mode 100644 index 000000000..5bdb233f6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.reference.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.canvas.reference</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.canvas.reference</h1> +<p class="desc">CanvasRenderingContext2D.canvas refers back to its canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("CanvasRenderingContext2D.canvas refers back to its canvas"); +_addTest(function(canvas, ctx) { + +_assertSame(ctx.canvas, canvas, "ctx.canvas", "canvas"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.exists.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.exists.html new file mode 100644 index 000000000..f8b768ad8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.exists.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.getcontext.exists</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.getcontext.exists</h1> +<p class="desc">The 2D context is implemented</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("The 2D context is implemented"); +_addTest(function(canvas, ctx) { + +_assertDifferent(canvas.getContext('2d'), null, "canvas.getContext('2d')", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.html new file mode 100644 index 000000000..f58911d04 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.getcontext.extraargs</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.getcontext.extraargs</h1> +<p class="desc">The 2D context ignores extra getContext arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("The 2D context ignores extra getContext arguments"); +_addTest(function(canvas, ctx) { + +_assertDifferent(canvas.getContext('2d', false, {}, [], 1, "2"), null, "canvas.getContext('2d', false, {}, [], 1, \"2\")", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.shared.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.shared.html new file mode 100644 index 000000000..a678a135f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.shared.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.getcontext.shared</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.getcontext.shared</h1> +<p class="desc">getContext('2d') returns objects which share canvas state</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("getContext('2d') returns objects which share canvas state"); +_addTest(function(canvas, ctx) { + +var ctx2 = canvas.getContext('2d'); +ctx.fillStyle = '#f00'; +ctx2.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.unique.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.unique.html new file mode 100644 index 000000000..d4d4a0d17 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.unique.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.getcontext.unique</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.getcontext.unique</h1> +<p class="desc">getContext('2d') returns the same object</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getContext('2d') returns the same object"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext('2d'), canvas.getContext('2d'), "canvas.getContext('2d')", "canvas.getContext('2d')"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.scaled-manual.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.scaled-manual.html new file mode 100644 index 000000000..6ea8ba4b9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.scaled-manual.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.scaled</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.scaled</h1> +<p class="desc">CSS-scaled canvases get drawn correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="25" style="width: 100px; height: 50px"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="2d.scaled.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("CSS-scaled canvases get drawn correctly"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#00f'; +ctx.fillRect(0, 0, 50, 25); +ctx.fillStyle = '#0ff'; +ctx.fillRect(0, 0, 25, 10); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.scaled.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.scaled.png Binary files differnew file mode 100644 index 000000000..875407769 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.scaled.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.exists.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.exists.html new file mode 100644 index 000000000..f29f13926 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.exists.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.type.exists</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.type.exists</h1> +<p class="desc">The 2D context interface is a property of 'window'</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("The 2D context interface is a property of 'window'"); +_addTest(function(canvas, ctx) { + +_assert(window.CanvasRenderingContext2D, "window.CanvasRenderingContext2D"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.extend.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.extend.html new file mode 100644 index 000000000..f4dfea879 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.extend.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.type.extend</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.type.extend</h1> +<p class="desc">Interface methods can be added</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Interface methods can be added"); +_addTest(function(canvas, ctx) { + +window.CanvasRenderingContext2D.prototype.fillRectGreen = function (x, y, w, h) +{ + this.fillStyle = '#0f0'; + this.fillRect(x, y, w, h); +}; +ctx.fillStyle = '#f00'; +ctx.fillRectGreen(0, 0, 100, 50); +_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.prototype.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.prototype.html new file mode 100644 index 000000000..9888d7b6a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.prototype.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.type.prototype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.type.prototype</h1> +<p class="desc">window.CanvasRenderingContext2D.prototype are not [[Writable]] and not [[Configurable]], and its methods are [[Configurable]].</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("window.CanvasRenderingContext2D.prototype are not [[Writable]] and not [[Configurable]], and its methods are [[Configurable]]."); +_addTest(function(canvas, ctx) { + +_assert(window.CanvasRenderingContext2D.prototype, "window.CanvasRenderingContext2D.prototype"); +_assert(window.CanvasRenderingContext2D.prototype.fill, "window.CanvasRenderingContext2D.prototype.fill"); +window.CanvasRenderingContext2D.prototype = null; +_assert(window.CanvasRenderingContext2D.prototype, "window.CanvasRenderingContext2D.prototype"); +delete window.CanvasRenderingContext2D.prototype; +_assert(window.CanvasRenderingContext2D.prototype, "window.CanvasRenderingContext2D.prototype"); +window.CanvasRenderingContext2D.prototype.fill = 1; +_assertSame(window.CanvasRenderingContext2D.prototype.fill, 1, "window.CanvasRenderingContext2D.prototype.fill", "1"); +delete window.CanvasRenderingContext2D.prototype.fill; +_assertSame(window.CanvasRenderingContext2D.prototype.fill, undefined, "window.CanvasRenderingContext2D.prototype.fill", "undefined"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.replace.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.replace.html new file mode 100644 index 000000000..1e3337732 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d.type.replace.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.type.replace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.type.replace</h1> +<p class="desc">Interface methods can be overridden</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Interface methods can be overridden"); +_addTest(function(canvas, ctx) { + +var fillRect = window.CanvasRenderingContext2D.prototype.fillRect; +window.CanvasRenderingContext2D.prototype.fillRect = function (x, y, w, h) +{ + this.fillStyle = '#0f0'; + fillRect.call(this, x, y, w, h); +}; +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/contains.json b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/contains.json new file mode 100644 index 000000000..3f56f4fd8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/contains.json @@ -0,0 +1,10 @@ +[ + { + "id": "color-spaces-and-color-correction", + "original_id": "color-spaces-and-color-correction" + }, + { + "id": "security-with-canvas-elements", + "original_id": "security-with-canvas-elements" + } +]
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.arguments.missing.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.arguments.missing.html new file mode 100644 index 000000000..37ae4e800 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.arguments.missing.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: context.arguments.missing</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>context.arguments.missing</h1> +<p class="desc"></p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test(""); +_addTest(function(canvas, ctx) { + +assert_throws(new TypeError(), function() { canvas.getContext(); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.casesensitive.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.casesensitive.html new file mode 100644 index 000000000..5c64f7a04 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.casesensitive.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: context.casesensitive</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>context.casesensitive</h1> +<p class="desc">Context name "2D" is unrecognised; matching is case sensitive</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name \"2D\" is unrecognised; matching is case sensitive"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext('2D'), null, "canvas.getContext('2D')", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.emptystring.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.emptystring.html new file mode 100644 index 000000000..8f8b44a23 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.emptystring.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: context.emptystring</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>context.emptystring</h1> +<p class="desc">getContext with empty string returns null</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getContext with empty string returns null"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext(""), null, "canvas.getContext(\"\")", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badname.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badname.html new file mode 100644 index 000000000..75f442774 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badname.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: context.unrecognised.badname</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.badname</h1> +<p class="desc">getContext with unrecognised context name returns null</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getContext with unrecognised context name returns null"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext('This is not an implemented context in any real browser'), null, "canvas.getContext('This is not an implemented context in any real browser')", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badsuffix.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badsuffix.html new file mode 100644 index 000000000..2f65ae3c8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badsuffix.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: context.unrecognised.badsuffix</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.badsuffix</h1> +<p class="desc">Context name "2d" plus a suffix is unrecognised</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name \"2d\" plus a suffix is unrecognised"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext("2d#"), null, "canvas.getContext(\"2d#\")", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.nullsuffix.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.nullsuffix.html new file mode 100644 index 000000000..1607fec86 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.nullsuffix.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: context.unrecognised.nullsuffix</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.nullsuffix</h1> +<p class="desc">Context name "2d" plus a "\0" suffix is unrecognised</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name \"2d\" plus a \"\\0\" suffix is unrecognised"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext("2d\0"), null, "canvas.getContext(\"2d\\0\")", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.unicode.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.unicode.html new file mode 100644 index 000000000..c4eb943c2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.unicode.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: context.unrecognised.unicode</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.unicode</h1> +<p class="desc">Context name which kind of looks like "2d" is unrecognised</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name which kind of looks like \"2d\" is unrecognised"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext("2\uFF44"), null, "canvas.getContext(\"2\\uFF44\")", "null"); // Fullwidth Latin Small Letter D + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.basic.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.basic.html new file mode 100644 index 000000000..0bae976e8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: fallback.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>fallback.basic</h1> +<p class="desc">Fallback content is inserted into the DOM</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Fallback content is inserted into the DOM"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.childNodes.length, 1, "canvas.childNodes.length", "1"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.multiple.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.multiple.html new file mode 100644 index 000000000..5c89be519 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.multiple.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: fallback.multiple</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>fallback.multiple</h1> +<p class="desc">Fallback content with multiple elements</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL</p><p class="fallback">FAIL</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Fallback content with multiple elements"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.childNodes.length, 2, "canvas.childNodes.length", "2"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.nested.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.nested.html new file mode 100644 index 000000000..e84739c85 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.nested.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: fallback.nested</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>fallback.nested</h1> +<p class="desc">Fallback content containing another canvas (mostly testing parsers)</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><canvas><p class="fallback">FAIL (fallback content)</p></canvas><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Fallback content containing another canvas (mostly testing parsers)"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.childNodes.length, 2, "canvas.childNodes.length", "2"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/historical.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/historical.html new file mode 100644 index 000000000..58ebc5769 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/historical.html @@ -0,0 +1,77 @@ +<!doctype html> +<meta charset=utf-8> +<title>Historical canvas features</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +var canvas, context; +setup(function() { + canvas = document.createElement("canvas"); + context = canvas.getContext('2d'); + path2d = new Path2D(); +}); +function t(member, obj) { + var name = obj === canvas ? "Canvas" : String(obj).match(/\[object (\S+)\]/)[1]; + test(function() { + assert_false(member in obj); + }, name + " support for " + member); +} +// added in https://github.com/whatwg/html/commit/0ecbf0e010df16d9c6d11eef6b2c58419158c4da +// renamed in https://github.com/whatwg/html/commit/2542a12cb25ee93534cbed1f31b5e1bc05fcdd0e +t("supportsContext", canvas); + +// removed in https://github.com/whatwg/html/commit/2cfb8e3f03d3166842d2ad0f661459d26e2a40eb +t("probablySupportsContext", canvas); + +// removed in https://github.com/whatwg/html/commit/ef72f55da4acdf266174225c6ca8bf2a650d0219 +t("width", context); +t("height", context); + +// removed in https://github.com/whatwg/html/commit/740634d0f30a3b76e9da166ac2fa8835fcc073ab +t("setContext", canvas); +t("transferControlToProxy", canvas); +t("CanvasProxy", window); +t("commit", canvas); +test(function() { + assert_throws(new TypeError(), function() { + new CanvasRenderingContext2D(); + }, 'no arguments'); + assert_throws(new TypeError(), function() { + new CanvasRenderingContext2D(1, 1); + }, 'with arguments'); +}, "CanvasRenderingContext2D constructors"); + +// removed in https://github.com/whatwg/html/commit/e1d04f49a38e2254a783c28987457a95a47d9511 +t("addPathByStrokingPath", path2d); +t("addText", path2d); +t("addPathByStrokingText", path2d); + +// renamed in https://github.com/whatwg/html/commit/fcb0756dd94d96df9b8355741d82fcd5ca0a6154 +test(function() { + var canvas = document.createElement('canvas'); + var context = canvas.getContext('bitmaprenderer'); + if (context) { + assert_false('transferImageBitmap' in context); + } +}, 'ImageBitmapRenderingContext support for transferImageBitmap'); + +// renamed in https://github.com/whatwg/html/commit/3aec2a7e04a3402201afd29c224b57fa54497517 +t('Path', window); + +// removed in https://github.com/whatwg/html/commit/d5759b0435091e4858c9bff90319cbe5b040eda2 +t('toDataURLHD', canvas); +t('toBlobHD', canvas); +t('createImageDataHD', context); +t('getImageDataHD', context); +t('putImageDataHD', context); +test(function() { + if ('ImageData' in window) { + assert_false('resolution' in new ImageData(1, 1)); + } +}, 'ImageData support for resolution'); + +// dropped/renamed in https://github.com/whatwg/html/commit/ff07c6d630fb986f6c4f64b2fb87387b4f89647d +t('drawSystemFocusRing', context); +t('drawCustomFocusRing', context); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.html new file mode 100644 index 000000000..f680d504c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.colour</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.colour</h1> +<p class="desc">Initial state is transparent black</p> + +<p class="notes">Output should be transparent black (not transparent anything-else), but manual +verification can only confirm that it's transparent - it's not possible to make +the actual blackness visible. + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.colour.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Initial state is transparent black"); +_addTest(function(canvas, ctx) { + +_assertPixel(canvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.png Binary files differnew file mode 100644 index 000000000..eeedd0ff0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.2dstate.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.2dstate.html new file mode 100644 index 000000000..b51253a6e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.2dstate.html @@ -0,0 +1,103 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.2dstate</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.2dstate</h1> +<p class="desc">Resetting the canvas state resets 2D state variables</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets 2D state variables"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +var default_val; + +default_val = ctx.strokeStyle; +ctx.strokeStyle = "#ff0000"; +canvas.width = 100; +_assertSame(ctx.strokeStyle, default_val, "ctx.strokeStyle", "default_val"); + +default_val = ctx.fillStyle; +ctx.fillStyle = "#ff0000"; +canvas.width = 100; +_assertSame(ctx.fillStyle, default_val, "ctx.fillStyle", "default_val"); + +default_val = ctx.globalAlpha; +ctx.globalAlpha = 0.5; +canvas.width = 100; +_assertSame(ctx.globalAlpha, default_val, "ctx.globalAlpha", "default_val"); + +default_val = ctx.lineWidth; +ctx.lineWidth = 0.5; +canvas.width = 100; +_assertSame(ctx.lineWidth, default_val, "ctx.lineWidth", "default_val"); + +default_val = ctx.lineCap; +ctx.lineCap = "round"; +canvas.width = 100; +_assertSame(ctx.lineCap, default_val, "ctx.lineCap", "default_val"); + +default_val = ctx.lineJoin; +ctx.lineJoin = "round"; +canvas.width = 100; +_assertSame(ctx.lineJoin, default_val, "ctx.lineJoin", "default_val"); + +default_val = ctx.miterLimit; +ctx.miterLimit = 0.5; +canvas.width = 100; +_assertSame(ctx.miterLimit, default_val, "ctx.miterLimit", "default_val"); + +default_val = ctx.shadowOffsetX; +ctx.shadowOffsetX = 5; +canvas.width = 100; +_assertSame(ctx.shadowOffsetX, default_val, "ctx.shadowOffsetX", "default_val"); + +default_val = ctx.shadowOffsetY; +ctx.shadowOffsetY = 5; +canvas.width = 100; +_assertSame(ctx.shadowOffsetY, default_val, "ctx.shadowOffsetY", "default_val"); + +default_val = ctx.shadowBlur; +ctx.shadowBlur = 5; +canvas.width = 100; +_assertSame(ctx.shadowBlur, default_val, "ctx.shadowBlur", "default_val"); + +default_val = ctx.shadowColor; +ctx.shadowColor = "#ff0000"; +canvas.width = 100; +_assertSame(ctx.shadowColor, default_val, "ctx.shadowColor", "default_val"); + +default_val = ctx.globalCompositeOperation; +ctx.globalCompositeOperation = "copy"; +canvas.width = 100; +_assertSame(ctx.globalCompositeOperation, default_val, "ctx.globalCompositeOperation", "default_val"); + +default_val = ctx.font; +ctx.font = "25px serif"; +canvas.width = 100; +_assertSame(ctx.font, default_val, "ctx.font", "default_val"); + +default_val = ctx.textAlign; +ctx.textAlign = "center"; +canvas.width = 100; +_assertSame(ctx.textAlign, default_val, "ctx.textAlign", "default_val"); + +default_val = ctx.textBaseline; +ctx.textBaseline = "bottom"; +canvas.width = 100; +_assertSame(ctx.textBaseline, default_val, "ctx.textBaseline", "default_val"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.clip.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.clip.html new file mode 100644 index 000000000..044ccc583 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.clip.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.clip</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.clip</h1> +<p class="desc">Resetting the canvas state resets the current clip region</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the current clip region"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.rect(0, 0, 1, 1); +ctx.clip(); +canvas.width = 100; +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 20,20, 0,255,0,255, "20,20", "0,255,0,255"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.html new file mode 100644 index 000000000..0d02f40d6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.different</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.different</h1> +<p class="desc">Changing size resets canvas to transparent black</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.reset.different.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Changing size resets canvas to transparent black"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 50, 50); +_assertPixel(canvas, 20,20, 255,0,0,255, "20,20", "255,0,0,255"); +canvas.width = 50; +_assertPixel(canvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.png Binary files differnew file mode 100644 index 000000000..d83fdd55b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.gradient.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.gradient.html new file mode 100644 index 000000000..a1a8516d3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.gradient.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.gradient</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.gradient</h1> +<p class="desc">Resetting the canvas state does not invalidate any existing gradients</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state does not invalidate any existing gradients"); +_addTest(function(canvas, ctx) { + +canvas.width = 50; +var g = ctx.createLinearGradient(0, 0, 100, 0); +g.addColorStop(0, '#0f0'); +g.addColorStop(1, '#0f0'); +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = g; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.html new file mode 100644 index 000000000..ab59ce9a1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.path</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.path</h1> +<p class="desc">Resetting the canvas state resets the current path</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.reset.path.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the current path"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.rect(0, 0, 100, 50); +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fill(); +_assertPixel(canvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.png Binary files differnew file mode 100644 index 000000000..eeedd0ff0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.pattern.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.pattern.html new file mode 100644 index 000000000..f569d21f2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.pattern.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.pattern</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.pattern</h1> +<p class="desc">Resetting the canvas state does not invalidate any existing patterns</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state does not invalidate any existing patterns"); +_addTest(function(canvas, ctx) { + +canvas.width = 30; +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 30, 50); +var p = ctx.createPattern(canvas, 'repeat-x'); +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.html new file mode 100644 index 000000000..b0bf73f8f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.same</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.same</h1> +<p class="desc">Setting size (not changing the value) resets canvas to transparent black</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.reset.same.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Setting size (not changing the value) resets canvas to transparent black"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 50, 50); +_assertPixel(canvas, 20,20, 255,0,0,255, "20,20", "255,0,0,255"); +canvas.width = 100; +_assertPixel(canvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.png Binary files differnew file mode 100644 index 000000000..eeedd0ff0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.transform.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.transform.html new file mode 100644 index 000000000..c5a92ca0f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.transform.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: initial.reset.transform</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.transform</h1> +<p class="desc">Resetting the canvas state resets the current transformation matrix</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the current transformation matrix"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.scale(0.1, 0.1); +canvas.width = 100; +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 20,20, 0,255,0,255, "20,20", "0,255,0,255"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.dataURI.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.dataURI.html new file mode 100644 index 000000000..d13057915 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.dataURI.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.dataURI</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.dataURI</h1> +<p class="desc">data: URIs do not count as different-origin, and do not taint the canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("data: URIs do not count as different-origin, and do not taint the canvas"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var data = canvas.toDataURL(); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 0); + canvas.toDataURL(); // should be permitted + _assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); +}); +img.src = data; + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.html new file mode 100644 index 000000000..918bf8f8f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.drawImage.canvas</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.drawImage.canvas</h1> +<p class="desc">drawImage of unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("drawImage of unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +ctx.drawImage(canvas2, 0, 0); +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.html new file mode 100644 index 000000000..48f808aa6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.drawImage.image</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.drawImage.image</h1> +<p class="desc">drawImage of different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("drawImage of different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +ctx.drawImage(document.getElementById('yellow.png'), 0, 0); +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.html new file mode 100644 index 000000000..2997ef9bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.fillStyle</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.fillStyle</h1> +<p class="desc">Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx.fillStyle = p; +ctx.fillStyle = 'red'; +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.html new file mode 100644 index 000000000..8980d2d53 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.strokeStyle</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.strokeStyle</h1> +<p class="desc">Setting strokeStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting strokeStyle to a pattern of an unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx.strokeStyle = p; +ctx.strokeStyle = 'red'; +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.html new file mode 100644 index 000000000..bb5fd58e6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.timing</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.timing</h1> +<p class="desc">Pattern safety depends on whether the source was origin-clean, not on whether it still is clean</p> + +<p class="notes">Disagrees with spec on "is" vs "was" +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Pattern safety depends on whether the source was origin-clean, not on whether it still is clean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.fillStyle = '#0f0'; +ctx2.fillRect(0, 0, 100, 50); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); // make canvas2 origin-unclean +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.html new file mode 100644 index 000000000..b81c6dfa5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.create</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.create</h1> +<p class="desc">Creating an unclean pattern does not make the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Creating an unclean pattern does not make the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.html new file mode 100644 index 000000000..67e40bdaa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.cross</h1> +<p class="desc">Using an unclean pattern makes the target canvas origin-unclean, not the pattern canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Using an unclean pattern makes the target canvas origin-unclean, not the pattern canvas"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +var p = ctx2.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); +canvas2.toDataURL(); +ctx2.getImageData(0, 0, 1, 1); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.html new file mode 100644 index 000000000..758c30a12 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.image.fillStyle</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.image.fillStyle</h1> +<p class="desc">Setting fillStyle to a pattern of a different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting fillStyle to a pattern of a different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.fillStyle = p; +ctx.fillStyle = 'red'; +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.html new file mode 100644 index 000000000..771523973 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.image.strokeStyle</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.image.strokeStyle</h1> +<p class="desc">Setting strokeStyle to a pattern of a different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting strokeStyle to a pattern of a different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.strokeStyle = p; +ctx.strokeStyle = 'red'; +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.html new file mode 100644 index 000000000..28e65f90e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.reset</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>security.reset</h1> +<p class="desc">Resetting the canvas state does not reset the origin-clean flag</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state does not reset the origin-clean flag"); +_addTest(function(canvas, ctx) { + +canvas.width = 50; +ctx.drawImage(document.getElementById('yellow.png'), 0, 0); +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); +canvas.width = 100; +assert_throws("SECURITY_ERR", function() { canvas.toDataURL(); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.html new file mode 100644 index 000000000..004636d84 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.default</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.default</h1> +<p class="desc">Default width/height when attributes are missing</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" ><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.default.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Default width/height when attributes are missing"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assert(!canvas.hasAttribute('width'), "!canvas.hasAttribute('width')"); +_assert(!canvas.hasAttribute('height'), "!canvas.hasAttribute('height')"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.get.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.get.png Binary files differnew file mode 100644 index 000000000..47830c83e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.get.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.html new file mode 100644 index 000000000..cd6796e07 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.idl</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.idl</h1> +<p class="desc">Getting/setting width/height IDL attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Getting/setting width/height IDL attributes"); +_addTest(function(canvas, ctx) { + +canvas.width = "100"; +canvas.height = "100"; +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); + +canvas.width = "+1.5e2"; +canvas.height = "0x96"; +_assertSame(canvas.width, 150, "canvas.width", "150"); +_assertSame(canvas.height, 150, "canvas.height", "150"); + +canvas.width = 200 - Math.pow(2, 32); +canvas.height = 200 - Math.pow(2, 32); +_assertSame(canvas.width, 200, "canvas.width", "200"); +_assertSame(canvas.height, 200, "canvas.height", "200"); + +canvas.width = 301.999; +canvas.height = 301.001; +_assertSame(canvas.width, 301, "canvas.width", "301"); +_assertSame(canvas.height, 301, "canvas.height", "301"); + +canvas.width = "400x"; +canvas.height = "foo"; +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.set.zero.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.set.zero.html new file mode 100644 index 000000000..a10ac5443 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.set.zero.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.idl.set.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.idl.set.zero</h1> +<p class="desc">Setting width/height IDL attributes to 0</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting width/height IDL attributes to 0"); +_addTest(function(canvas, ctx) { + +canvas.width = 0; +canvas.height = 0; +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html new file mode 100644 index 000000000..ccf579e05 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.decimal</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.decimal</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100.999" height="100.999"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.decimal.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100.999', "canvas.getAttribute('width')", "'100.999'"); +_assertSame(canvas.getAttribute('height'), '100.999', "canvas.getAttribute('height')", "'100.999'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.em.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.em.html new file mode 100644 index 000000000..84614691a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.em.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.em</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.em</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100em" height="100em"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.em.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100em', "canvas.getAttribute('width')", "'100em'"); +_assertSame(canvas.getAttribute('height'), '100em', "canvas.getAttribute('height')", "'100em'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.em.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.em.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.em.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.empty.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.empty.html new file mode 100644 index 000000000..04a19b44a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.empty.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.empty</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.empty</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="" height=""><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.empty.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), '', "canvas.getAttribute('width')", "''"); +_assertSame(canvas.getAttribute('height'), '', "canvas.getAttribute('height')", "''"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.empty.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.empty.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.empty.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.exp.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.exp.html new file mode 100644 index 000000000..7a7c72692 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.exp.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.exp</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.exp</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100e1" height="100e1"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.exp.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100e1', "canvas.getAttribute('width')", "'100e1'"); +_assertSame(canvas.getAttribute('height'), '100e1', "canvas.getAttribute('height')", "'100e1'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.exp.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.exp.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.exp.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.hex.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.hex.html new file mode 100644 index 000000000..7532d7753 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.hex.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.hex</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.hex</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="0x100" height="0x100"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "0px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"0px\""); +_assertSame(canvas.getAttribute('width'), '0x100', "canvas.getAttribute('width')", "'0x100'"); +_assertSame(canvas.getAttribute('height'), '0x100', "canvas.getAttribute('height')", "'0x100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.junk.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.junk.html new file mode 100644 index 000000000..8dca5ef3c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.junk.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.junk</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.junk</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="#!?" height="#!?"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.junk.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), '#!?', "canvas.getAttribute('width')", "'#!?'"); +_assertSame(canvas.getAttribute('height'), '#!?', "canvas.getAttribute('height')", "'#!?'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.junk.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.junk.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.junk.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.minus.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.minus.html new file mode 100644 index 000000000..c901dffc5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.minus.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.minus</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.minus</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="-100" height="-100"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.minus.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), '-100', "canvas.getAttribute('width')", "'-100'"); +_assertSame(canvas.getAttribute('height'), '-100', "canvas.getAttribute('height')", "'-100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.minus.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.minus.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.minus.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.octal.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.octal.html new file mode 100644 index 000000000..efdcfeb3a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.octal.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.octal</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.octal</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="0100" height="0100"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.octal.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '0100', "canvas.getAttribute('width')", "'0100'"); +_assertSame(canvas.getAttribute('height'), '0100', "canvas.getAttribute('height')", "'0100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.octal.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.octal.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.octal.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.onlyspace.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.onlyspace.html new file mode 100644 index 000000000..11948581e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.onlyspace.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.onlyspace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.onlyspace</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width=" " height=" "><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.onlyspace.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), ' ', "canvas.getAttribute('width')", "' '"); +_assertSame(canvas.getAttribute('height'), ' ', "canvas.getAttribute('height')", "' '"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.onlyspace.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.onlyspace.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.onlyspace.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.percent.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.percent.html new file mode 100644 index 000000000..9073424e2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.percent.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.percent</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.percent</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100%" height="100%"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.percent.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100%', "canvas.getAttribute('width')", "'100%'"); +_assertSame(canvas.getAttribute('height'), '100%', "canvas.getAttribute('height')", "'100%'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.percent.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.percent.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.percent.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.plus.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.plus.html new file mode 100644 index 000000000..816f381d4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.plus.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.plus</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.plus</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="+100" height="+100"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.plus.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '+100', "canvas.getAttribute('width')", "'+100'"); +_assertSame(canvas.getAttribute('height'), '+100', "canvas.getAttribute('height')", "'+100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.plus.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.plus.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.plus.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.space.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.space.html new file mode 100644 index 000000000..417674d18 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.space.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.space</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.space</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width=" 100" height=" 100"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.space.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), ' 100', "canvas.getAttribute('width')", "' 100'"); +_assertSame(canvas.getAttribute('height'), ' 100', "canvas.getAttribute('height')", "' 100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.space.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.space.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.space.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.trailingjunk.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.trailingjunk.html new file mode 100644 index 000000000..76c6db05f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.trailingjunk.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.trailingjunk</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.trailingjunk</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100#!?" height="100#!?"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.trailingjunk.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100#!?', "canvas.getAttribute('width')", "'100#!?'"); +_assertSame(canvas.getAttribute('height'), '100#!?', "canvas.getAttribute('height')", "'100#!?'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.trailingjunk.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.trailingjunk.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.trailingjunk.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.html new file mode 100644 index 000000000..dc8eab52b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.whitespace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.whitespace</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="
+ 100" height="
+ 100"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.parse.whitespace.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '\n\t\x0c100', "canvas.getAttribute('width')", "'\\n\\t\\x0c100'"); +_assertSame(canvas.getAttribute('height'), '\n\t\x0c100', "canvas.getAttribute('height')", "'\\n\\t\\x0c100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.zero.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.zero.html new file mode 100644 index 000000000..e42ebeb24 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.zero.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.parse.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.parse.zero</h1> +<p class="desc">Parsing of non-negative integers</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="0" height="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "0px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"0px\""); +_assertSame(canvas.getAttribute('width'), '0', "canvas.getAttribute('width')", "'0'"); +_assertSame(canvas.getAttribute('height'), '0', "canvas.getAttribute('height')", "'0'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.html new file mode 100644 index 000000000..e77ca8ee0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.reflect.setcontent</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.reflect.setcontent</h1> +<p class="desc">Setting content attributes updates IDL and content attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.reflect.setcontent.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Setting content attributes updates IDL and content attributes"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '120'); +canvas.setAttribute('height', '60'); +_assertSame(canvas.getAttribute('width'), '120', "canvas.getAttribute('width')", "'120'"); +_assertSame(canvas.getAttribute('height'), '60', "canvas.getAttribute('height')", "'60'"); +_assertSame(canvas.width, 120, "canvas.width", "120"); +_assertSame(canvas.height, 60, "canvas.height", "60"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.png Binary files differnew file mode 100644 index 000000000..47830c83e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.html new file mode 100644 index 000000000..152288291 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.reflect.setidl</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.reflect.setidl</h1> +<p class="desc">Setting IDL attributes updates IDL and content attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.reflect.setidl.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Setting IDL attributes updates IDL and content attributes"); +_addTest(function(canvas, ctx) { + +canvas.width = 120; +canvas.height = 60; +_assertSame(canvas.getAttribute('width'), '120', "canvas.getAttribute('width')", "'120'"); +_assertSame(canvas.getAttribute('height'), '60', "canvas.getAttribute('height')", "'60'"); +_assertSame(canvas.width, 120, "canvas.width", "120"); +_assertSame(canvas.height, 60, "canvas.height", "60"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.png Binary files differnew file mode 100644 index 000000000..47830c83e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidlzero.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidlzero.html new file mode 100644 index 000000000..2bace5a33 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidlzero.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.reflect.setidlzero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.reflect.setidlzero</h1> +<p class="desc">Setting IDL attributes to 0 updates IDL and content attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting IDL attributes to 0 updates IDL and content attributes"); +_addTest(function(canvas, ctx) { + +canvas.width = 0; +canvas.height = 0; +_assertSame(canvas.getAttribute('width'), '0', "canvas.getAttribute('width')", "'0'"); +_assertSame(canvas.getAttribute('height'), '0', "canvas.getAttribute('height')", "'0'"); +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.html new file mode 100644 index 000000000..58fb899e0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.removed</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.removed</h1> +<p class="desc">Removing content attributes reverts to default size</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="120" height="60"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.removed.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Removing content attributes reverts to default size"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 120, "canvas.width", "120"); +canvas.removeAttribute('width'); +_assertSame(canvas.width, 300, "canvas.width", "300"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.png Binary files differnew file mode 100644 index 000000000..1ebf30d8a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.set.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.set.png Binary files differnew file mode 100644 index 000000000..47830c83e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.set.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html new file mode 100644 index 000000000..0f4fb69fa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.decimal</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.decimal</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.decimal.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '100.999'); +canvas.setAttribute('height', '100.999'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100.999', "canvas.getAttribute('width')", "'100.999'"); +_assertSame(canvas.getAttribute('height'), '100.999', "canvas.getAttribute('height')", "'100.999'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.em.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.em.html new file mode 100644 index 000000000..5768d1727 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.em.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.em</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.em</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.em.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '100em'); +canvas.setAttribute('height', '100em'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100em', "canvas.getAttribute('width')", "'100em'"); +_assertSame(canvas.getAttribute('height'), '100em', "canvas.getAttribute('height')", "'100em'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.em.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.em.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.em.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.empty.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.empty.html new file mode 100644 index 000000000..65a5bc0d9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.empty.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.empty</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.empty</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.empty.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', ''); +canvas.setAttribute('height', ''); +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), '', "canvas.getAttribute('width')", "''"); +_assertSame(canvas.getAttribute('height'), '', "canvas.getAttribute('height')", "''"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.empty.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.empty.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.empty.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.exp.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.exp.html new file mode 100644 index 000000000..673edad56 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.exp.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.exp</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.exp</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.exp.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '100e1'); +canvas.setAttribute('height', '100e1'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100e1', "canvas.getAttribute('width')", "'100e1'"); +_assertSame(canvas.getAttribute('height'), '100e1', "canvas.getAttribute('height')", "'100e1'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.exp.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.exp.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.exp.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.hex.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.hex.html new file mode 100644 index 000000000..e6fde5329 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.hex.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.hex</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.hex</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '0x100'); +canvas.setAttribute('height', '0x100'); +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "0px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"0px\""); +_assertSame(canvas.getAttribute('width'), '0x100', "canvas.getAttribute('width')", "'0x100'"); +_assertSame(canvas.getAttribute('height'), '0x100', "canvas.getAttribute('height')", "'0x100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.junk.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.junk.html new file mode 100644 index 000000000..77b50fd11 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.junk.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.junk</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.junk</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.junk.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '#!?'); +canvas.setAttribute('height', '#!?'); +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), '#!?', "canvas.getAttribute('width')", "'#!?'"); +_assertSame(canvas.getAttribute('height'), '#!?', "canvas.getAttribute('height')", "'#!?'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.junk.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.junk.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.junk.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.minus.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.minus.html new file mode 100644 index 000000000..2bb09bbf2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.minus.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.minus</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.minus</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.minus.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '-100'); +canvas.setAttribute('height', '-100'); +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), '-100', "canvas.getAttribute('width')", "'-100'"); +_assertSame(canvas.getAttribute('height'), '-100', "canvas.getAttribute('height')", "'-100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.minus.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.minus.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.minus.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.octal.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.octal.html new file mode 100644 index 000000000..a6cb6d37f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.octal.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.octal</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.octal</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.octal.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '0100'); +canvas.setAttribute('height', '0100'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '0100', "canvas.getAttribute('width')", "'0100'"); +_assertSame(canvas.getAttribute('height'), '0100', "canvas.getAttribute('height')", "'0100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.octal.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.octal.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.octal.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.onlyspace.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.onlyspace.html new file mode 100644 index 000000000..5e2dd0c6c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.onlyspace.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.onlyspace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.onlyspace</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.onlyspace.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', ' '); +canvas.setAttribute('height', ' '); +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assertSame(canvas.getAttribute('width'), ' ', "canvas.getAttribute('width')", "' '"); +_assertSame(canvas.getAttribute('height'), ' ', "canvas.getAttribute('height')", "' '"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.onlyspace.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.onlyspace.png Binary files differnew file mode 100644 index 000000000..a72d04755 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.onlyspace.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.percent.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.percent.html new file mode 100644 index 000000000..2a41c667e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.percent.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.percent</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.percent</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.percent.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '100%'); +canvas.setAttribute('height', '100%'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100%', "canvas.getAttribute('width')", "'100%'"); +_assertSame(canvas.getAttribute('height'), '100%', "canvas.getAttribute('height')", "'100%'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.percent.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.percent.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.percent.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.plus.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.plus.html new file mode 100644 index 000000000..f384d82d3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.plus.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.plus</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.plus</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.plus.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '+100'); +canvas.setAttribute('height', '+100'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '+100', "canvas.getAttribute('width')", "'+100'"); +_assertSame(canvas.getAttribute('height'), '+100', "canvas.getAttribute('height')", "'+100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.plus.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.plus.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.plus.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.space.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.space.html new file mode 100644 index 000000000..8f8585279 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.space.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.space</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.space</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.space.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', ' 100'); +canvas.setAttribute('height', ' 100'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), ' 100', "canvas.getAttribute('width')", "' 100'"); +_assertSame(canvas.getAttribute('height'), ' 100', "canvas.getAttribute('height')", "' 100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.space.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.space.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.space.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.trailingjunk.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.trailingjunk.html new file mode 100644 index 000000000..f6d06bab0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.trailingjunk.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.trailingjunk</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.trailingjunk</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.trailingjunk.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '100#!?'); +canvas.setAttribute('height', '100#!?'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '100#!?', "canvas.getAttribute('width')", "'100#!?'"); +_assertSame(canvas.getAttribute('height'), '100#!?', "canvas.getAttribute('height')", "'100#!?'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.trailingjunk.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.trailingjunk.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.trailingjunk.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.whitespace.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.whitespace.html new file mode 100644 index 000000000..8a01f57ea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.whitespace.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.whitespace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.whitespace</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.setAttribute.whitespace.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '\r\n\t\x0c100'); +canvas.setAttribute('height', '\r\n\t\x0c100'); +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "100px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"100px\""); +_assertSame(canvas.getAttribute('width'), '\r\n\t\x0c100', "canvas.getAttribute('width')", "'\\r\\n\\t\\x0c100'"); +_assertSame(canvas.getAttribute('height'), '\r\n\t\x0c100', "canvas.getAttribute('height')", "'\\r\\n\\t\\x0c100'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.whitespace.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.whitespace.png Binary files differnew file mode 100644 index 000000000..f84267333 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.whitespace.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.zero.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.zero.html new file mode 100644 index 000000000..d1b05ad20 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.zero.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.setAttribute.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.setAttribute.zero</h1> +<p class="desc">Parsing of non-negative integers in setAttribute</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Parsing of non-negative integers in setAttribute"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '0'); +canvas.setAttribute('height', '0'); +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); +_assertSame(window.getComputedStyle(canvas, null).getPropertyValue("width"), "0px", "window.getComputedStyle(canvas, null).getPropertyValue(\"width\")", "\"0px\""); +_assertSame(canvas.getAttribute('width'), '0', "canvas.getAttribute('width')", "'0'"); +_assertSame(canvas.getAttribute('height'), '0', "canvas.getAttribute('height')", "'0'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.html new file mode 100644 index 000000000..3bab3e79d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: size.attributes.style</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.style</h1> +<p class="desc">Canvas size is independent of CSS resizing</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="30" style="width: 100px; height: 50px"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.style.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Canvas size is independent of CSS resizing"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 50, "canvas.width", "50"); +_assertSame(canvas.height, 30, "canvas.height", "30"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.png Binary files differnew file mode 100644 index 000000000..eeedd0ff0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.jpeg.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.jpeg.html new file mode 100644 index 000000000..37289fea2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.jpeg.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toBlob.jpeg</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toBlob.jpeg</h1> +<p class="desc">toBlob with image/jpeg returns a JPEG Blob</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toBlob with image/jpeg returns a JPEG Blob"); +_addTest(function(canvas, ctx) { + +canvas.toBlob(function(data){ + _assertSame(data.type, "image/jpeg", "data.type", "\"image/jpeg\""); +}, 'image/jpeg'); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.png.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.png.html new file mode 100644 index 000000000..80bc16c5a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.png.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toBlob.png</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toBlob.png</h1> +<p class="desc">toBlob with image/png returns a PNG Blob</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toBlob with image/png returns a PNG Blob"); +_addTest(function(canvas, ctx) { + +canvas.toBlob(function(data){ + _assertSame(data.type, "image/png", "data.type", "\"image/png\""); +}, 'image/png'); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.1.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.1.html new file mode 100644 index 000000000..969d4f538 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.1.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.arguments.1</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.arguments.1</h1> +<p class="desc">toDataURL ignores extra arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL ignores extra arguments"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/png', 'another argument that should not raise an exception'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.2.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.2.html new file mode 100644 index 000000000..378946608 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.2.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.arguments.2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.arguments.2</h1> +<p class="desc">toDataURL ignores extra arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL ignores extra arguments"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/png', 'another argument that should not raise an exception', 'and another'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.3.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.3.html new file mode 100644 index 000000000..236aba5ff --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.3.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.arguments.3</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.arguments.3</h1> +<p class="desc">toDataURL ignores extra arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL ignores extra arguments"); +_addTest(function(canvas, ctx) { + +// More arguments that should not raise exceptions +var data = canvas.toDataURL('image/png', null, null, null); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.bogustype.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.bogustype.html new file mode 100644 index 000000000..ade95f0ac --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.bogustype.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.bogustype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.bogustype</h1> +<p class="desc">toDataURL with a syntactically invalid type returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with a syntactically invalid type returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('bogus'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.default.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.default.html new file mode 100644 index 000000000..84f4c9ed4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.default.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.default</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.default</h1> +<p class="desc">toDataURL with no arguments returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with no arguments returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.html new file mode 100644 index 000000000..80a2fca42 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.alpha</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.alpha</h1> +<p class="desc">toDataURL with JPEG composites onto black</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.jpeg.alpha.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG composites onto black"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = 'rgba(128, 255, 128, 0.5)'; +ctx.fillRect(0, 0, 100, 50); +ctx.globalCompositeOperation = 'destination-over'; // should be ignored by toDataURL +var data = canvas.toDataURL('image/jpeg'); +ctx.globalCompositeOperation = 'source-over'; +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + var img = new Image(); + deferTest(); + img.onload = t.step_func_done(function () + { + ctx.drawImage(img, 0, 0); + _assertPixelApprox(canvas, 50,25, 63,127,63,255, "50,25", "63,127,63,255", 8); + }); + img.src = data; +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.png Binary files differnew file mode 100644 index 000000000..551871295 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.html new file mode 100644 index 000000000..a896cbb5c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.primarycolours</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.primarycolours</h1> +<p class="desc">toDataURL with JPEG handles simple colours correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.jpeg.primarycolours.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG handles simple colours correctly"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#ff0'; +ctx.fillRect(0, 0, 25, 40); +ctx.fillStyle = '#0ff'; +ctx.fillRect(25, 0, 50, 40); +ctx.fillStyle = '#00f'; +ctx.fillRect(75, 0, 25, 40); +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 40, 100, 10); +var data = canvas.toDataURL('image/jpeg'); // it is okay if this returns a PNG instead +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 0); + _assertPixelApprox(canvas, 12,20, 255,255,0,255, "12,20", "255,255,0,255", 8); + _assertPixelApprox(canvas, 50,20, 0,255,255,255, "50,20", "0,255,255,255", 8); + _assertPixelApprox(canvas, 87,20, 0,0,255,255, "87,20", "0,0,255,255", 8); + _assertPixelApprox(canvas, 50,45, 255,255,255,255, "50,45", "255,255,255,255", 8); +}); +img.src = data; + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.png Binary files differnew file mode 100644 index 000000000..cfd136900 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.html new file mode 100644 index 000000000..aad56cdd5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.quality.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.quality.basic</h1> +<p class="desc">toDataURL with JPEG uses the quality parameter</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.jpeg.quality.basic.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG uses the quality parameter"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#00f'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#0ff'; +ctx.fillRect(0, 3, 100, 1); +// Check for JPEG support first +var data = canvas.toDataURL('image/jpeg'); +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + var data_hi = canvas.toDataURL('image/jpeg', 0.99); + var data_lo = canvas.toDataURL('image/jpeg', 0.01); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + deferTest(); + var img_hi = new Image(); + img_hi.onload = function () + { + var img_lo = new Image(); + img_lo.onload = t.step_func_done(function () + { + ctx.drawImage(img_hi, 0, 0, 50, 50, 0, 0, 50, 50); + ctx.drawImage(img_lo, 0, 0, 50, 50, 50, 0, 50, 50); + _assert(data_hi.length > data_lo.length, "data_hi.length > data_lo.length"); + _assertPixelApprox(canvas, 25,25, 0,0,255,255, "25,25", "0,0,255,255", 8); + _assertPixelApprox(canvas, 75,25, 0,0,255,255, "75,25", "0,0,255,255", 32); + }); + img_lo.src = data_lo; + }; + img_hi.src = data_hi; +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.png Binary files differnew file mode 100644 index 000000000..2f8a0bc79 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.notnumber.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.notnumber.html new file mode 100644 index 000000000..3167e3c09 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.notnumber.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.quality.notnumber</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.quality.notnumber</h1> +<p class="desc">toDataURL with JPEG handles non-numeric quality parameters</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG handles non-numeric quality parameters"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#00f'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#0ff'; +ctx.fillRect(0, 3, 100, 1); +// Check for JPEG support first +var data = canvas.toDataURL('image/jpeg'); +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + _assertSame(canvas.toDataURL('image/jpeg', 'bogus'), data, "canvas.toDataURL('image/jpeg', 'bogus')", "data"); + _assertSame(canvas.toDataURL('image/jpeg', {}), data, "canvas.toDataURL('image/jpeg', {})", "data"); + _assertSame(canvas.toDataURL('image/jpeg', null), data, "canvas.toDataURL('image/jpeg', null)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', undefined), data, "canvas.toDataURL('image/jpeg', undefined)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', true), data, "canvas.toDataURL('image/jpeg', true)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', '0.01'), data, "canvas.toDataURL('image/jpeg', '0.01')", "data"); +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.outsiderange.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.outsiderange.html new file mode 100644 index 000000000..885dc99b8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.outsiderange.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.quality.outsiderange</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.quality.outsiderange</h1> +<p class="desc">toDataURL with JPEG handles out-of-range quality parameters</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG handles out-of-range quality parameters"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#00f'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#0ff'; +ctx.fillRect(0, 3, 100, 1); +// Check for JPEG support first +var data = canvas.toDataURL('image/jpeg'); +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + _assertSame(canvas.toDataURL('image/jpeg', 10), data, "canvas.toDataURL('image/jpeg', 10)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', -10), data, "canvas.toDataURL('image/jpeg', -10)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', 1.01), data, "canvas.toDataURL('image/jpeg', 1.01)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', -0.01), data, "canvas.toDataURL('image/jpeg', -0.01)", "data"); + + _assert(canvas.toDataURL('image/jpeg', 1).length >= canvas.toDataURL('image/jpeg', 0.9).length, "canvas.toDataURL('image/jpeg', 1).length >= canvas.toDataURL('image/jpeg', 0.9).length"); + _assert(canvas.toDataURL('image/jpeg', 0).length <= canvas.toDataURL('image/jpeg', 0.1).length, "canvas.toDataURL('image/jpeg', 0).length <= canvas.toDataURL('image/jpeg', 0.1).length"); +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpg.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpg.html new file mode 100644 index 000000000..df12aeebc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpg.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.jpg</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpg</h1> +<p class="desc">toDataURL with image/jpg is invalid type hence returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with image/jpg is invalid type hence returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/jpg'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.ascii.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.ascii.html new file mode 100644 index 000000000..b95c8285b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.ascii.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.lowercase.ascii</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.lowercase.ascii</h1> +<p class="desc">toDataURL type is case-insensitive</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL type is case-insensitive"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('ImAgE/PnG'); +assert_regexp_match(data, /^data:image\/png[;,]/); + +// If JPEG is supported at all, it must be supported case-insensitively +data = canvas.toDataURL('image/jpeg'); +if (data.match(/^data:image\/jpeg[;,]/)) { + data = canvas.toDataURL('ImAgE/JpEg'); + assert_regexp_match(data, /^data:image\/jpeg[;,]/); +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.unicode.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.unicode.html new file mode 100644 index 000000000..ab06d59ec --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.unicode.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.lowercase.unicode</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.lowercase.unicode</h1> +<p class="desc">toDataURL type is ASCII-case-insensitive</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL type is ASCII-case-insensitive"); +_addTest(function(canvas, ctx) { + +// Use LATIN CAPITAL LETTER I WITH DOT ABOVE (Unicode lowercase is "i") +var data = canvas.toDataURL('\u0130mage/png'); +assert_regexp_match(data, /^data:image\/png[;,]/); + +var data = canvas.toDataURL('\u0130mage/jpeg'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.nocontext.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.nocontext.html new file mode 100644 index 000000000..07fb85dc8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.nocontext.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.nocontext</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.nocontext</h1> +<p class="desc">toDataURL works before any context has been got</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL works before any context has been got"); +_addTest(function(canvas, ctx) { + var no_context_data = canvas.toDataURL(); + var ctx = canvas.getContext('2d'); + ctx.rect(0, 0, 100, 50); + ctx.fillStyle = "rgba(0, 0, 0, 0)"; + ctx.fill(); + var data = canvas.toDataURL(); + assert_equals(no_context_data, data); +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.html new file mode 100644 index 000000000..cc067b737 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.png.complexcolours</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.png.complexcolours</h1> +<p class="desc">toDataURL with PNG handles non-primary and non-solid colours correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.png.complexcolours.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with PNG handles non-primary and non-solid colours correctly"); +_addTest(function(canvas, ctx) { + +// (These values are chosen to survive relatively alright through being premultiplied) +ctx.fillStyle = 'rgba(1, 3, 254, 1)'; +ctx.fillRect(0, 0, 25, 25); +ctx.fillStyle = 'rgba(8, 252, 248, 0.75)'; +ctx.fillRect(25, 0, 25, 25); +ctx.fillStyle = 'rgba(6, 10, 250, 0.502)'; +ctx.fillRect(50, 0, 25, 25); +ctx.fillStyle = 'rgba(12, 16, 244, 0.25)'; +ctx.fillRect(75, 0, 25, 25); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 25); + // (The alpha values do not really survive float->int conversion, so just + // do approximate comparisons) + _assertPixel(canvas, 12,40, 1,3,254,255, "12,40", "1,3,254,255"); + _assertPixelApprox(canvas, 37,40, 8,252,248,191, "37,40", "8,252,248,191", 2); + _assertPixelApprox(canvas, 62,40, 6,10,250,127, "62,40", "6,10,250,127", 4); + _assertPixelApprox(canvas, 87,40, 12,16,244,63, "87,40", "12,16,244,63", 8); +}); +img.src = canvas.toDataURL(); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.png Binary files differnew file mode 100644 index 000000000..9bc814658 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.html new file mode 100644 index 000000000..39917eb23 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.png</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.png</h1> +<p class="desc">toDataURL with image/png returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with image/png returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/png'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.html new file mode 100644 index 000000000..b962821d7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.png.primarycolours</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.png.primarycolours</h1> +<p class="desc">toDataURL with PNG handles simple colours correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.png.primarycolours.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with PNG handles simple colours correctly"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#ff0'; +ctx.fillRect(0, 0, 25, 40); +ctx.fillStyle = '#0ff'; +ctx.fillRect(25, 0, 50, 40); +ctx.fillStyle = '#00f'; +ctx.fillRect(75, 0, 25, 40); +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 40, 100, 10); +var data = canvas.toDataURL(); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 0); + _assertPixel(canvas, 12,20, 255,255,0,255, "12,20", "255,255,0,255"); + _assertPixel(canvas, 50,20, 0,255,255,255, "50,20", "0,255,255,255"); + _assertPixel(canvas, 87,20, 0,0,255,255, "87,20", "0,0,255,255"); + _assertPixel(canvas, 50,45, 255,255,255,255, "50,45", "255,255,255,255"); +}); +img.src = data; + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.png Binary files differnew file mode 100644 index 000000000..cfd136900 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.unrecognised.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.unrecognised.html new file mode 100644 index 000000000..3526cc3a2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.unrecognised.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.unrecognised</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.unrecognised</h1> +<p class="desc">toDataURL with an unhandled type returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with an unhandled type returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/example'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zeroheight.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zeroheight.html new file mode 100644 index 000000000..04c113216 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zeroheight.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.zeroheight</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.zeroheight</h1> +<p class="desc">toDataURL on zero-size canvas returns 'data:,'</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" height="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL on zero-size canvas returns 'data:,'"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +_assertSame(data, 'data:,', "data", "'data:,'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerosize.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerosize.html new file mode 100644 index 000000000..7d2913d02 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerosize.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.zerosize</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.zerosize</h1> +<p class="desc">toDataURL on zero-size canvas returns 'data:,'</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="0" height="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL on zero-size canvas returns 'data:,'"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +_assertSame(data, 'data:,', "data", "'data:,'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerowidth.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerowidth.html new file mode 100644 index 000000000..d4020aa51 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerowidth.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: toDataURL.zerowidth</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.zerowidth</h1> +<p class="desc">toDataURL on zero-size canvas returns 'data:,'</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL on zero-size canvas returns 'data:,'"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +_assertSame(data, 'data:,', "data", "'data:,'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.delete.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.delete.html new file mode 100644 index 000000000..98b67b909 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.delete.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: type.delete</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>type.delete</h1> +<p class="desc">window.HTMLCanvasElement interface object is [[Configurable]]</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("window.HTMLCanvasElement interface object is [[Configurable]]"); +_addTest(function(canvas, ctx) { + +_assertSame(delete window.HTMLCanvasElement, true, "delete window.HTMLCanvasElement", "true"); +_assertSame(window.HTMLCanvasElement, undefined, "window.HTMLCanvasElement", "undefined"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.exists.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.exists.html new file mode 100644 index 000000000..04aa97570 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.exists.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: type.exists</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>type.exists</h1> +<p class="desc">HTMLCanvasElement is a property of window</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement is a property of window"); +_addTest(function(canvas, ctx) { + +_assert(window.HTMLCanvasElement, "window.HTMLCanvasElement"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.extend.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.extend.html new file mode 100644 index 000000000..572273083 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.extend.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: type.extend</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>type.extend</h1> +<p class="desc">HTMLCanvasElement methods can be added, and the new methods used by canvases</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement methods can be added, and the new methods used by canvases"); +_addTest(function(canvas, ctx) { + +window.HTMLCanvasElement.prototype.getZero = function () { return 0; }; +_assertSame(canvas.getZero(), 0, "canvas.getZero()", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.name.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.name.html new file mode 100644 index 000000000..a514effaa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.name.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: type.name</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>type.name</h1> +<p class="desc">HTMLCanvasElement type and toString</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement type and toString"); +_addTest(function(canvas, ctx) { + +_assertSame(Object.prototype.toString.call(canvas), '[object HTMLCanvasElement]', "Object.prototype.toString.call(canvas)", "'[object HTMLCanvasElement]'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.prototype.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.prototype.html new file mode 100644 index 000000000..029a9fbbd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.prototype.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: type.prototype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>type.prototype</h1> +<p class="desc">window.HTMLCanvasElement has prototype, which is { ReadOnly, DontDelete }. prototype has getContext, which is not</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("window.HTMLCanvasElement has prototype, which is { ReadOnly, DontDelete }. prototype has getContext, which is not"); +_addTest(function(canvas, ctx) { + +_assert(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype"); +_assert(window.HTMLCanvasElement.prototype.getContext, "window.HTMLCanvasElement.prototype.getContext"); +window.HTMLCanvasElement.prototype = null; +_assert(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype"); +delete window.HTMLCanvasElement.prototype; +_assert(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype"); +window.HTMLCanvasElement.prototype.getContext = 1; +_assertSame(window.HTMLCanvasElement.prototype.getContext, 1, "window.HTMLCanvasElement.prototype.getContext", "1"); +delete window.HTMLCanvasElement.prototype.getContext; +_assertSame(window.HTMLCanvasElement.prototype.getContext, undefined, "window.HTMLCanvasElement.prototype.getContext", "undefined"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.replace.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.replace.html new file mode 100644 index 000000000..70a08066e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.replace.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: type.replace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>type.replace</h1> +<p class="desc">HTMLCanvasElement methods can be replaced, and the replacement methods used by canvases</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement methods can be replaced, and the replacement methods used by canvases"); +_addTest(function(canvas, ctx) { + +window.HTMLCanvasElement.prototype.getContext = function (name) { return 0; }; +_assertSame(canvas.getContext('2d'), 0, "canvas.getContext('2d')", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-dimension.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-dimension.html new file mode 100644 index 000000000..608ed331c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-dimension.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: dimension</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-embed-element"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<embed src="/images/blue.png" height="100" width="100" id="test"> +<script> + test(function () { + var height = getComputedStyle(document.getElementById("test"), false)["height"]; + assert_equals(height, "100px", "The height of the embed element should be 100px."); + }, "Check the actual length of the embed element's height"); + + test(function () { + var width = getComputedStyle(document.getElementById("test"), false)["width"]; + assert_equals(width, "100px", "The width of the embed element should be 100px."); + }, "Check the actual length of the embed element's width"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-document.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-document.html new file mode 100644 index 000000000..3d44678cf --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-document.html @@ -0,0 +1,17 @@ +<!doctype html> +<meta charset="utf-8"> +<title>HTML Test: The embed element represents a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<meta name="assert" content="Check if the embed element represents a document when a text/html resource source is used"> +<body> + <script type="application/javascript"> + window.childLoaded = false; + async_test(function() { + addEventListener("load", this.step_func_done(function() { + assert_true(window.childLoaded); + })); + }, "Test document type embedding"); + </script> + <embed src="embed-iframe.html"> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-iframe.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-iframe.html new file mode 100644 index 000000000..f9b1bfdb5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-iframe.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<body> + <script type="application/javascript"> + parent.childLoaded = true; + </script> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-ignored-in-media-element.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-ignored-in-media-element.html new file mode 100644 index 000000000..d29d520f0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-ignored-in-media-element.html @@ -0,0 +1,22 @@ +<!doctype html> +<meta charset="utf-8"> +<title>HTML Test: The embed element represents a document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<meta name="assert" content="Check if the embed element is ignored when used inside a media element"> +<script type="application/javascript"> + window.childLoaded = false; + async_test(function() { + addEventListener("load", this.step_func_done(function() { + assert_false(window.childLoaded); + })); + }, "Test embed being ignored inside media element"); +</script> +<body> + <video> + <embed type="text/html" src="embed-iframe.html" /> + </video> + <audio> + <embed type="text/html" src="embed-iframe.html" /> + </audio> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback-subdocument.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback-subdocument.html new file mode 100644 index 000000000..a2c2a9399 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback-subdocument.html @@ -0,0 +1,4 @@ +<script> + var varName = location.search.substr(1); + parent[varName] = true; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html new file mode 100644 index 000000000..52fa01b91 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html @@ -0,0 +1,38 @@ +<!doctype html> +<meta charset=utf-8> +<title>Ensure that embed elements inside object elements load when the objects + fall back but not otherwise</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> + var child1Loaded = false; + var child2Loaded = false; + var child3Loaded = false; + var parent3Loaded = false; +</script> +<object> + <embed src="embed-in-object-fallback-subdocument.html?child1Loaded"> +</object> +<object> + <embed id="two" src="embed-in-object-fallback-subdocument.html?child2Loaded"> + <!-- Something that forces the embed to be in the tree before the <object> + is done parsing --> + <script> + test(function() { + assert_equals(document.getElementById("two").localName, + "embed"); + }, "We have the right embed element"); + </script> +</object> +<object data="embed-in-object-fallback-subdocument.html?parent3Loaded"> + <embed src="embed-in-object-fallback-subdocument.html?child3Loaded"> +</object> +<script> + var t = async_test("Check that the right things loaded"); + onload = t.step_func_done(function() { + assert_true(child1Loaded, "child 1 should load"); + assert_true(child2Loaded, "child 2 should load"); + assert_false(child3Loaded, "child 3 should not load"); + assert_true(parent3Loaded, "parent 3 should load"); + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-01.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-01.html new file mode 100644 index 000000000..e66bd4a90 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-01.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: The embed element without src and type attributes represents nothing</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-embed-element"> +<link rel="match" href="embed-represent-nothing-ref.html"> +<meta name="assert" content="Check if the embed element without src and type attributes represents nothing"> +<style> + embed { + background-color: red; + height: 100px; + width: 100px; + } +</style> +<body> + <p>Test passes if there is <strong>no red</strong>.</p> + <embed> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-02.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-02.html new file mode 100644 index 000000000..65cd67238 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-02.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: The embed element represents nothing when its type and src attributs are removed</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-embed-element"> +<link rel="match" href="embed-represent-nothing-ref.html"> +<meta name="assert" content="Check if the embed element represents nothing when its src and type attributes are removed"> +<style> + embed { + background-color: red; + height: 100px; + width: 100px; + } +</style> +<body> + <p>Test passes if there is <strong>no red</strong>.</p> + <embed id="embed" src="/images/red-16x16.png" type="image/png"> + <script> + document.getElementById("embed").removeAttribute("src"); + document.getElementById("embed").removeAttribute("type"); + </script> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-03.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-03.html new file mode 100644 index 000000000..a16f3794a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-03.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: The embed element represents nothing when it has a media ancestor</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-embed-element"> +<link rel="match" href="embed-represent-nothing-ref.html"> +<meta name="assert" content="Check if the embed element represents nothing when it has a media ancestor"> +<style> + embed { + background-color: red; + height: 100px; + width: 100px; + } +</style> +<body> + <p>Test passes if there is <strong>no red</strong>.</p> + <video> + <embed src="/images/red-16x16.png"> + </video> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-04.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-04.html new file mode 100644 index 000000000..7cc1b668a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-04.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: The embed element represents nothing when it has an object ancestor</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-embed-element"> +<link rel="match" href="embed-represent-nothing-ref.html"> +<meta name="assert" content="Check if the embed element represents nothing when it has a object ancestor that is not showing its fallback content"> +<style> + embed { + background-color: red; + height: 100px; + width: 100px; + } +</style> +<body> + <p>Test passes if there is <strong>no red</strong>.</p> + <object type="application/x-shockwave-flash"> + <embed src="/images/red-16x16.png"> + </object> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-ref.html b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-ref.html new file mode 100644 index 000000000..91d680deb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-ref.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Embed Reftest Reference</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<body> + <p>Test passes if there is <strong>no red</strong>.</p> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_child.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_child.html new file mode 100644 index 000000000..738ceee52 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_child.html @@ -0,0 +1,14 @@ +<body> + Child. + <iframe id="grandchild" src="change_grandchild.html"></iframe> +</body> +<script> + var timer = window.setInterval(poll, 100); + function poll() { + if (document.body.getAttribute("data-contains-grandchild")) { + var grandchild = document.getElementById("grandchild"); + window.frameElement.parentNode.appendChild(grandchild); + window.clearTimeout(timer); + } + } +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_grandchild.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_grandchild.html new file mode 100644 index 000000000..885622c2b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_grandchild.html @@ -0,0 +1,4 @@ +<body>Grandchild.</body> +<script> + window.frameElement.parentNode.setAttribute("data-contains-grandchild", true); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_parentage.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_parentage.html new file mode 100644 index 000000000..1d62ccc48 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/change_parentage.html @@ -0,0 +1,22 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Change the frame heriarchy</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body> + <iframe src="change_child.html"></iframe> +</body> +<script> + async_test(function(t) { + var timer = window.setInterval(t.step_func(poll), 100); + function poll() { + // We wait for the grandchild's script to set the custom attribtue. + // Note that if this test passes, the grandchild's script must have been run twice, + // once to trigger the move from the child to here, and once to pass this test. + if (document.body.getAttribute("data-contains-grandchild")) { + window.clearTimeout(timer); + t.done(); + } + } + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_child.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_child.html new file mode 100644 index 000000000..8b44fe805 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_child.html @@ -0,0 +1,12 @@ +<script src="iframe_harness.js"></script> +<body> + <iframe src="cross_origin_grandchild.html"></iframe> +</body> +<script> + send_test_results({ + "id": '79a52de8-4222-427e-92db-caec28e75f8e', + "parent": window.parent !== window, + "grandparent": window.parent.parent === window.parent, + "top": window.top === window.parent, + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_grandchild.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_grandchild.html new file mode 100644 index 000000000..1eff64af1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_grandchild.html @@ -0,0 +1,11 @@ +<script src="iframe_harness.js"></script> +<body> +</body> +<script> + send_test_results({ + "id": '6c8da65d-2c5e-44ef-bb0b-b8b9849aab19', + "parent": window.parent !== window, + "grandparent": window.parent.parent !== window.parent, + "top": window.top === window.parent.parent, + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_parentage.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_parentage.html new file mode 100644 index 000000000..cd27b8ea7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross_origin_parentage.html @@ -0,0 +1,19 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Check the frame heriarchy</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="iframe_harness.js"></script> +<body> + <iframe src="http://www1.web-platform.test:8000/html/semantics/embedded-content/the-iframe-element/cross_origin_child.html"></iframe> +</body> +<script> + get_test_results('bffa23ee-b45a-4e9a-9405-87ab437d5cfa'); + get_test_results('79a52de8-4222-427e-92db-caec28e75f8e'); + get_test_results('6c8da65d-2c5e-44ef-bb0b-b8b9849aab19'); + send_test_results({ + "id": 'bffa23ee-b45a-4e9a-9405-87ab437d5cfa', + "parent": window.parent === window, + "top": window.top === window, + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/historical.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/historical.html new file mode 100644 index 000000000..850a52f46 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/historical.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>Historical iframe element features should not be supported</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +function t(property) { + test(function() { + assert_false(property in document.createElement('iframe')); + }, 'iframe.' + property + ' should not be supported'); +} + +// added in https://github.com/whatwg/html/commit/f6490f17f577fa3478791b29ad8c2b586418001f +// removed in https://github.com/whatwg/html/commit/1490eba4dba5ab476f0981443a86c01acae01311 +t('seamless'); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html new file mode 100644 index 000000000..da5791a2d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-allowfullscreen.html @@ -0,0 +1,55 @@ +<!doctype html> +<meta charset=utf-8> +<title>Check how allowfullscreen affects fullscreen enabled flag</title> +<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org"> +<link rel="author" title="Mozilla" href="https://www.mozilla.org"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/browsers.html#initialise-the-document-object"> +<link rel="help" href="https://fullscreen.spec.whatwg.org/#fullscreen-enabled-flag"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<div id="log"></div> +<script> + async_test(function(t) { + var iframe = document.createElement("iframe"); + iframe.src = "support/blank.htm"; + var eventWatcher = new EventWatcher(t, iframe, "load"); + document.body.appendChild(iframe); + t.add_cleanup(function() { + document.body.removeChild(iframe); + }); + + assert_true(document.fullscreenEnabled, "Top level document has fullscreen enabled flag set"); + eventWatcher.wait_for("load").then(t.step_func_done(function() { + assert_false(iframe.contentDocument.fullscreenEnabled, "Document inside iframe without allowfullscreen attribute should not have fullscreen enabled flag set"); + iframe.setAttribute("allowfullscreen", true); + assert_true(iframe.contentDocument.fullscreenEnabled, "Fullscreen should be allowed when allowfullscreen attribute is set"); + iframe.removeAttribute("allowfullscreen"); + assert_false(iframe.contentDocument.fullscreenEnabled, "Fullscreen should be denied when allowfullscreen attribute is removed"); + })); + }, "iframe-allowfullscreen"); + + /* Fullscreen enabled flag with about:blank */ + + function test_allowfullscreen_noload(setup_iframe, check) { + var iframe = document.createElement("iframe"); + setup_iframe(iframe); + document.body.appendChild(iframe); + check(iframe.contentDocument); + document.body.removeChild(iframe); + } + + test(function() { + test_allowfullscreen_noload(function() {}, function(doc) { + assert_false(doc.fullscreenEnabled, "Fullscreen should not be enabled without allowfullscreen attribute"); + }); + }, "iframe-noload-noallowfullscreen"); + + test(function() { + test_allowfullscreen_noload(function(iframe) { + iframe.setAttribute("allowfullscreen", true); + }, function(doc) { + assert_true(doc.fullscreenEnabled, "Fullscreen should be enabled with allowfullscreen attribute"); + }); + }, "iframe-noload-allowfullscreen"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.html new file mode 100644 index 000000000..ac8bd5e05 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.html @@ -0,0 +1,17 @@ +<!doctype html> +<meta charset=utf-8> +<title>Append iframe element to its own child document</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe id=x></iframe> +<script> +test(function() { + var iframe = document.getElementById('x'); + var childWindow = iframe.contentWindow; + assert_equals(childWindow.parent, window); + childWindow.document.body.appendChild(iframe); + assert_equals(childWindow.parent, null); + assert_equals(iframe.contentWindow, null); + assert_equals(childWindow.document.body.firstChild, iframe); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-load-event.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-load-event.html new file mode 100644 index 000000000..d245bf0b9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-load-event.html @@ -0,0 +1,48 @@ +<!doctype html> +<meta charset=utf-8> +<title>Test some sanity behavior around iframe load/error events</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<body> +<script> +async_test(function(t) { + var obj = document.createElement("iframe"); + obj.onload = t.step_func_done(function(e){ + assert_true(obj.contentWindow instanceof Window, "The iframe element should represent a nested browsing context.") + assert_equals(Object.getPrototypeOf(e).constructor, Event, "The load event should use the Event interface."); + assert_true(e.isTrusted, "The load event should be a trusted event."); + assert_false(e.cancelable, "The load event should not be a cancelable event."); + assert_false(e.bubbles, "The load event should not be a bubble event."); + assert_equals(e.target, obj, "The load event target should be the corresponding object element."); + }); + + obj.onerror = t.step_func_done(function(e){ + assert_unreached("The error event should not be fired."); + }); + + var url = URL.createObjectURL(new Blob([""], { type: "text/html" })); + + obj.src = url; + document.body.appendChild(obj); +}, "load event of blob URL"); + +async_test(function(t) { + var obj = document.createElement("iframe"); + obj.onload = t.step_func_done(function(e){ + assert_true(obj.contentWindow instanceof Window, "The object element should represent a nested browsing context.") + assert_equals(Object.getPrototypeOf(e).constructor, Event, "The load event should use the Event interface."); + assert_true(e.isTrusted, "The load event should be a trusted event."); + assert_false(e.cancelable, "The load event should not be a cancelable event."); + assert_false(e.bubbles, "The load event should not be a bubble event."); + assert_equals(e.target, obj, "The load event target should be the corresponding object element."); + }); + + obj.onerror = t.step_func_done(function(e){ + assert_unreached("The error event should not be fired."); + }); + + document.body.appendChild(obj); +}, "load event of initial about:blank"); + +</script> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-with-base-ref.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-with-base-ref.html new file mode 100644 index 000000000..21f11d195 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-with-base-ref.html @@ -0,0 +1,9 @@ +<!doctype html> +<html> +<head> + <title>iframe Without Base Tag</title> +</head> +<body> + <iframe src="support/blank.htm"> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-with-base.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-with-base.html new file mode 100644 index 000000000..4637a41a4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe-with-base.html @@ -0,0 +1,11 @@ +<!doctype html> +<html> +<head> + <title>iframe With Base Tag</title> + <link rel="match" href="iframe-with-base-ref.html"> + <base href="support/"> +</head> +<body> + <iframe src="blank.htm"> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_harness.js b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_harness.js new file mode 100644 index 000000000..f4ef511d1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_harness.js @@ -0,0 +1,26 @@ +function get_test_results(id) { + async_test(function(test) { + var timer = window.setInterval(test.step_func(loop), 100); + function loop() { + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'stash.py?id=' + id); + xhr.onreadystatechange = test.step_func(function() { + assert_equals(xhr.status, 200); + if (xhr.responseText) { + assert_equals(xhr.responseText, "OK"); + test.done(); + window.clearTimeout(timer); + } + }); + xhr.send(); + } + }); +} + +function send_test_results(results) { + var ok = true; + for (result in results) { ok = ok && results[result]; } + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'stash.py?id=' + results.id); + xhr.send(ok ? "OK" : "FAIL: " + JSON.stringify(results)); +} diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm new file mode 100644 index 000000000..d6c2abe7d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm @@ -0,0 +1,53 @@ +<!DOCTYPE html><html><head><title>javascript: URL creating a document in an about:blank iframe</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-iframe-element"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#process-the-iframe-attributes"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id="log">FAILED (test did not run)</div> + +<iframe src="about:blank" name="ifr1"></iframe> +<iframe src="" name="ifr2"></iframe> +<iframe src="./" name="ifr3"></iframe> + +<script> +var test = async_test(); +var results = {}; +var expected = { + ifr1:{url:"about:blank", sameDom: true}, + ifr2:{url:"about:blank", sameDom: true}, + ifr3:{url: location.href.replace(/\/[^\/]*$/, '/'), sameDom: true }, + ifr4:{url:"about:blank", sameDom: true} +} + +var js_url = 'javascript:"<html><script>var sameDom = false; try{var cn = top.document.body.className;sameDom = true;}catch(e){}; parent.postMessage( {url: document.URL, name: name, sameDom: sameDom}, \'*\')<\/script><body><p>JS-generated document</p></body></<html>";' +window.addEventListener('message', function(e){ + var ifr = e.data.name; + results[ifr] = e.data; + test.step(function(){ + assert_equals(results[ifr].url, expected[ifr].url); + assert_equals(results[ifr].sameDom, expected[ifr].sameDom); + }, 'Testing URL and details of IFRAME ' + ifr); + if(Object.keys(results).length === Object.keys(expected).length){ + test.done(); + } +}, false); + +var ifr = document.createElement('iframe'); +ifr.name = 'ifr4'; +document.body.appendChild(ifr); + +window.onload = function () { + for (var i = 0, frame, frames = document.getElementsByTagName('iframe'); frame = frames[i]; i++) { + try{ + frame.src = js_url; + }catch(e){ + results[frame.name] = 'Exception on setting!'; + } + }; +} + +</script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_script.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_script.html new file mode 100644 index 000000000..cd05f2246 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_script.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<meta charset="uft-8"> +<title>HTML Test: iframe_sandbox_allow_scripts</title> +<link rel="author" title="Intel" href="http://www.intel.com/"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-iframe-sandbox"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-iframe-element"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<div id="log"></div> +<script> + // Set up all our script stuff before the iframe starts loading, so we don't + // miss any messages from it. + var step1 = false; + var t = async_test("iframe_sandbox_allow_scripts"); + + setup({timeout:1000}); + window.addEventListener("message", callback1, false); + + function run() { + window.removeEventListener("message", callback1, false); + document.getElementById("testIframe").sandbox = "allow-scripts"; + document.getElementById("testIframe").contentWindow.location.reload(); + window.addEventListener("message", callback2, false); + } + + function callback1(e) { + step1= !step1; + } + + function callback2(e) { + t.step(function () { + assert_false(step1, "[allow-scripts] is not set."); + assert_equals(e.data, "Script executed", "[allow-scripts] is set."); + }); + t.done(); + } + + // Make sure the iframe loads before we mess with it. + window.addEventListener("load", function() { + // The load event might fire before a message from the child comes in... + // Wait a bit to see if that message does come in. + setTimeout(run, 500); + }); +</script> +<iframe id="testIframe" src="support/sandbox_allow_script.html" sandbox="allow-same-origin" style="display:none"></iframe> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html new file mode 100644 index 000000000..342d42203 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html @@ -0,0 +1,25 @@ +<!doctype html> +<meta charset=utf-8> +<title>Check that popups from a sandboxed iframe escape the sandbox if + allow-popups-to-escape-sandbox is used</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"> +</iframe> +<script> + var t = async_test(); + var ourOrigin; + onmessage = t.step_func(function(e) { + assert_equals(e.data, "hello", "This is our origin getter message"); + ourOrigin = e.origin; + + onmessage = t.step_func_done(function(e) { + assert_equals(e.origin, "null", "It came from a sandboxed iframe"); + assert_equals(e.data.data, undefined, "Should have the right message"); + assert_equals(e.data.origin, ourOrigin, "Should have escaped the sandbox"); + }); + + document.querySelector("iframe").src = "iframe_sandbox_popups_helper-1.html"; + }); + postMessage("hello", "*"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html new file mode 100644 index 000000000..40ffbb1e0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html @@ -0,0 +1,31 @@ +<!doctype html> +<meta charset=utf-8> +<title>Check that popups from a sandboxed iframe escape the sandbox if + allow-popups-to-escape-sandbox is used</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"> +</iframe> +<script> + var t = async_test(); + var ourOrigin; + onmessage = t.step_func(function(e) { + assert_equals(e.data, "hello", "This is our origin getter message"); + ourOrigin = e.origin; + + onmessage = t.step_func_done(function(e) { + assert_equals(e.origin, "null", "It came from a sandboxed iframe"); + assert_equals(e.data.data, undefined, "Should have the right message"); + assert_equals(e.data.origin, ourOrigin, "Should have escaped the sandbox"); + }); + + var iframe = document.querySelector("iframe"); + iframe.onload = function() { + frames[0].postMessage("start", "*"); + } + iframe.src = "iframe_sandbox_popups_helper-2.html"; + }); + addEventListener("load", function() { + postMessage("hello", "*"); + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html new file mode 100644 index 000000000..2d35fd5fc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html @@ -0,0 +1,25 @@ +<!doctype html> +<meta charset=utf-8> +<title>Check that popups from a sandboxed iframe escape the sandbox if + allow-popups-to-escape-sandbox is used</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"> +</iframe> +<script> + var t = async_test(); + var ourOrigin; + onmessage = t.step_func(function(e) { + assert_equals(e.data, "hello", "This is our origin getter message"); + ourOrigin = e.origin; + + onmessage = t.step_func_done(function(e) { + assert_equals(e.origin, "null", "It came from a sandboxed iframe"); + assert_equals(e.data.data, undefined, "Should have the right message"); + assert_equals(e.data.origin, ourOrigin, "Should have escaped the sandbox"); + }); + + document.querySelector("iframe").src = "iframe_sandbox_popups_helper-3.html"; + }); + postMessage("hello", "*"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-1.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-1.html new file mode 100644 index 000000000..6b120f15d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-1.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<script> + if (opener) { + // We're the popup. Send back our state. What we really want to send is + // our origin, but that will come automatically. + opener.postMessage(undefined, "*"); + self.close(); + } else { + // We're the child. Start listening for messages and open ourselves as the + // popup. + onmessage = function (e) { + parent.postMessage({ data: e.data, origin: e.origin }, "*"); + }; + popupWin = window.open(location.href); + } +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html new file mode 100644 index 000000000..9c393fc95 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<body> +<script> + if (opener) { + // We're the popup. Send back our state. What we really want to send is + // our origin, but that will come automatically. + opener.postMessage(undefined, "*"); + self.close(); + } else { + // We're the child. Start listening for messages from our parent and open + // ourselves as the popup when we get the "start" message. + onmessage = function (e) { + if (e.data == "start") { + // Now listen for messages from the thing we plan to open. + onmessage = function(e) { + parent.postMessage({ data: e.data, origin: e.origin }, "*"); + } + + var a = document.createElement("a"); + a.href = location.href; + a.target = "_blank"; + document.body.appendChild(a); + a.click(); + } + }; + } +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html new file mode 100644 index 000000000..ef3e59037 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<script> + if (opener) { + // We're the popup. Send back our state. What we really want to send is + // our origin, but that will come automatically. + opener.postMessage(undefined, "*"); + self.close(); + } else { + // We're the child. Start listening for messages and open ourselves as the + // popup. + onmessage = function (e) { + parent.postMessage({ data: e.data, origin: e.origin }, "*"); + }; + var popupWin = window.open(); + popupWin.location.href = location.href; + } +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html new file mode 100644 index 000000000..3dee96d67 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html @@ -0,0 +1,15 @@ +<!doctype html> +<meta charset=utf-8> +<title>Check that popups from a sandboxed iframe do not escape the sandbox</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> + var t = async_test(); + onmessage = t.step_func_done(function(e) { + assert_equals(e.origin, "null", "It came from a sandboxed iframe"); + assert_equals(e.data.data, undefined, "Should have the right message"); + assert_equals(e.data.origin, "null", "Should not have escaped the sandbox"); + }); +</script> +<iframe sandbox="allow-scripts allow-popups" + src="iframe_sandbox_popups_helper-1.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html new file mode 100644 index 000000000..27046db74 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset=utf-8> +<title>Check that popups from a sandboxed iframe do not escape the sandbox</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> + var t = async_test(); + onmessage = t.step_func_done(function(e) { + assert_equals(e.origin, "null", "It came from a sandboxed iframe"); + assert_equals(e.data.data, undefined, "Should have the right message"); + assert_equals(e.data.origin, "null", "Should not have escaped the sandbox"); + }); + addEventListener("load", function() { + frames[0].postMessage("start", "*"); + }); +</script> +<iframe sandbox="allow-scripts allow-popups" + src="iframe_sandbox_popups_helper-2.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html new file mode 100644 index 000000000..556387e14 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html @@ -0,0 +1,15 @@ +<!doctype html> +<meta charset=utf-8> +<title>Check that popups from a sandboxed iframe do not escape the sandbox</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> + var t = async_test(); + onmessage = t.step_func_done(function(e) { + assert_equals(e.origin, "null", "It came from a sandboxed iframe"); + assert_equals(e.data.data, undefined, "Should have the right message"); + assert_equals(e.data.origin, "null", "Should not have escaped the sandbox"); + }); +</script> +<iframe sandbox="allow-scripts allow-popups" + src="iframe_sandbox_popups_helper-3.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_01.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_01.html new file mode 100644 index 000000000..efd563f51 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_01.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<title>moving modified IFRAME in document (original page about:blank, DOM modification)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/#iframe-load-event-steps"> +<iframe src="about:blank"></iframe> +<div id="target"></div> +<script> +onload = function() { + var ifr = document.getElementsByTagName('iframe')[0]; + ifr.contentDocument.body.appendChild(ifr.contentDocument.createElement('p')).textContent = 'Modified document'; + setTimeout(function() { + ifr.onload = function() { + assert_equals(ifr.contentDocument.body.textContent.indexOf('Modified'), -1); + done(); + }; + document.getElementById('target').appendChild(ifr); + }, 100); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_02.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_02.html new file mode 100644 index 000000000..dbe266b29 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_02.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<title>moving modified IFRAME in document (original page about:blank, document.write modification)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/#iframe-load-event-steps"> +<iframe src="about:blank"></iframe> +<div id="target"></div> +<script> +onload = function() { + var ifr = document.getElementsByTagName('iframe')[0]; + ifr.contentDocument.open(); + ifr.contentDocument.write('Modified document'); + ifr.contentDocument.close(); + setTimeout(function() { + ifr.onload = function() { + assert_equals(ifr.contentDocument.body.textContent.indexOf('Modified'), -1); + done(); + }; + document.getElementById('target').appendChild(ifr); + }, 100); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_03.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_03.html new file mode 100644 index 000000000..c07dd42dc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_03.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<title>moving modified IFRAME in document (original page from server, DOM modification)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/#iframe-load-event-steps"> +<iframe src="support/blank.htm"></iframe> +<div id="target"></div> +<script> +onload = function() { + var ifr = document.getElementsByTagName('iframe')[0]; + ifr.contentDocument.body.appendChild(ifr.contentDocument.createElement('p')).textContent = 'Modified document'; + setTimeout(function() { + ifr.onload = function() { + assert_equals(ifr.contentDocument.body.textContent.indexOf('Modified'), -1); + done(); + }; + document.getElementById('target').appendChild(ifr); + }, 100); +} +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_04.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_04.html new file mode 100644 index 000000000..755cd45d3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_04.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<title>moving modified IFRAME in document (original page from server, document.write modification)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/#iframe-load-event-steps"> +<iframe src="support/blank.htm"></iframe> +<div id="target"></div> +<script> +onload = function(){ + var ifr = document.getElementsByTagName('iframe')[0]; + ifr.contentDocument.open(); + ifr.contentDocument.write('Modified document'); + ifr.contentDocument.close(); + setTimeout(function() { + ifr.onload = function () { + assert_equals(ifr.contentDocument.body.textContent.indexOf('Modified'), -1); + done(); + }; + document.getElementById('target').appendChild(ifr); + }, 100); +} +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_child.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_child.html new file mode 100644 index 000000000..a36e231fa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_child.html @@ -0,0 +1,12 @@ +<script src="iframe_harness.js"></script> +<body> + <iframe src="same_origin_grandchild.html"></iframe> +</body> +<script> + send_test_results({ + "id": '08782f28-e313-47ae-8cd7-419f3e194b0a', + "parent": window.parent !== window, + "grandparent": window.parent.parent === window.parent, + "top": window.top === window.parent, + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_grandchild.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_grandchild.html new file mode 100644 index 000000000..e7a2293b7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_grandchild.html @@ -0,0 +1,11 @@ +<script src="iframe_harness.js"></script> +<body> +</body> +<script> + send_test_results({ + "id": '66de8d44-7da7-47c7-9a52-41cba4f22bfe', + "parent": window.parent !== window, + "grandparent": window.parent.parent !== window.parent, + "top": window.top === window.parent.parent, + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_parentage.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_parentage.html new file mode 100644 index 000000000..a163eb8ee --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/same_origin_parentage.html @@ -0,0 +1,19 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Check the frame heriarchy</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="iframe_harness.js"></script> +<body> + <iframe src="same_origin_child.html"></iframe> +</body> +<script> + get_test_results('17381dae-9c3e-4661-9f2b-28eb07a5f2fc'); + get_test_results('08782f28-e313-47ae-8cd7-419f3e194b0a'); + get_test_results('66de8d44-7da7-47c7-9a52-41cba4f22bfe'); + send_test_results({ + "id": '17381dae-9c3e-4661-9f2b-28eb07a5f2fc', + "parent": window.parent === window, + "top": window.top === window, + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/stash.py b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/stash.py new file mode 100644 index 000000000..0b8693a90 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/stash.py @@ -0,0 +1,10 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + +def main(request, response): + if request.method == 'POST': + request.server.stash.put(request.GET["id"], request.body) + return '' + return request.server.stash.take(request.GET["id"]) diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/blank.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/blank.htm new file mode 100644 index 000000000..6c70bcfe4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/blank.htm @@ -0,0 +1 @@ +<html></html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/sandbox_allow_script.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/sandbox_allow_script.html new file mode 100644 index 000000000..95c30dec1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/sandbox_allow_script.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<meta charset="uft-8"> +<title>HTML Test: sandbox_allow_scripts</title> +<link rel="author" title="Intel" href="http://www.intel.com/"> +<div id="test">Before change</div> +<script> + parent.window.postMessage("Script executed", "*"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/3.jpg b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/3.jpg Binary files differnew file mode 100644 index 000000000..d30ac2ac3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/3.jpg diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/Image-constructor.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/Image-constructor.html new file mode 100644 index 000000000..1119f818f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/Image-constructor.html @@ -0,0 +1,29 @@ +<!DOCTYPE HTML> +<title>DOM Image constructor Test</title> +<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-img-element" /> +<meta name="assert" content="Tests the Image constructor for the img-element"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + + +<div id="log"></div> +<script> + test(function() { + var img = new Image(); + assert_true(img != undefined); + }, "Image constructor works"); + + test(function() { + assert_true(Image.prototype === HTMLImageElement.prototype); + }, "Image and HTMLImageElement share a prototype"); + + test(function() { + assert_true((new Image()).localName === "img"); + }, "Image localName is img"); + + test(function() { + assert_true((new Image()).namespaceURI === "http://www.w3.org/1999/xhtml"); + }, "Image namespace URI is correct"); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/brokenimg.jpg b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/brokenimg.jpg new file mode 100644 index 000000000..ccff177ae --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/brokenimg.jpg @@ -0,0 +1,4 @@ +<!DOCTYPE HTML> +<html> + +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/contains.json b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/contains.json new file mode 100644 index 000000000..9ac6d3d42 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/contains.json @@ -0,0 +1,60 @@ +[ + { + "id": "alt", + "original_id": "alt", + "children": [ + { + "id": "general-guidelines", + "original_id": "general-guidelines" + }, + { + "id": "a-link-or-button-containing-nothing-but-the-image", + "original_id": "a-link-or-button-containing-nothing-but-the-image" + }, + { + "id": "a-phrase-or-paragraph-with-an-alternative-graphical-representation-charts-diagrams-graphs-maps-illustrations", + "original_id": "a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations" + }, + { + "id": "a-short-phrase-or-label-with-an-alternative-graphical-representation-icons-logos", + "original_id": "a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos" + }, + { + "id": "text-that-has-been-rendered-to-a-graphic-for-typographical-effect", + "original_id": "text-that-has-been-rendered-to-a-graphic-for-typographical-effect" + }, + { + "id": "a-graphical-representation-of-some-of-the-surrounding-text", + "original_id": "a-graphical-representation-of-some-of-the-surrounding-text" + }, + { + "id": "a-purely-decorative-image-that-doesn-t-add-any-information", + "original_id": "a-purely-decorative-image-that-doesn't-add-any-information" + }, + { + "id": "a-group-of-images-that-form-a-single-larger-picture-with-no-links", + "original_id": "a-group-of-images-that-form-a-single-larger-picture-with-no-links" + }, + { + "id": "a-group-of-images-that-form-a-single-larger-picture-with-links", + "original_id": "a-group-of-images-that-form-a-single-larger-picture-with-links" + }, + { + "id": "a-key-part-of-the-content", + "original_id": "a-key-part-of-the-content" + }, + { + "id": "an-image-not-intended-for-the-user", + "original_id": "an-image-not-intended-for-the-user" + }, + { + "id": "guidance-for-markup-generators", + "original_id": "guidance-for-markup-generators" + }, + { + "id": "guidance-for-conformance-checkers", + "original_id": "guidance-for-conformance-checkers" + } + ] + } +]
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic.html new file mode 100644 index 000000000..f7d47b364 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic.html @@ -0,0 +1,37 @@ +<!doctype html> +<title>img current pixel density basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<img src="/images/green-256x256.png" data-expect="256"> +<img srcset="/images/green-256x256.png 1x" data-expect="256"> +<img srcset="/images/green-256x256.png 1.6x" data-expect="160"> +<img srcset="/images/green-256x256.png 2x" data-expect="128"> +<img srcset="/images/green-256x256.png 10000x" data-expect="0"> +<img srcset="/images/green-256x256.png 9e99999999999999999999999x" data-expect="0"> +<img srcset="/images/green-256x256.png 256w" sizes="256px" data-expect="256"> +<img srcset="/images/green-256x256.png 512w" sizes="256px" data-expect="128"> +<img srcset="/images/green-256x256.png 256w" sizes="512px" data-expect="512"> +<img srcset="/images/green-256x256.png 256w" sizes="1px" data-expect="1"> +<img srcset="/images/green-256x256.png 256w" sizes="0px" data-expect="0"> +<!-- SVG --> +<img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'%20height='20'><circle%20r='1'/></svg> 2x" data-expect="10"> +<img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'><circle%20r='1'/></svg> 2x" data-expect="10"> +<img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20height='20'><circle%20r='1'/></svg> 2x" data-expect="10"> +<script> +setup({explicit_done:true}); +onload = function() { + [].forEach.call(document.images, function(img) { + test(function() { + var expected = parseFloat(img.dataset.expect); + assert_equals(img.width, expected, 'width'); + assert_equals(img.height, expected, 'height'); + assert_equals(img.clientWidth, expected, 'clientWidth'); + assert_equals(img.clientHeight, expected, 'clientHeight'); + assert_equals(img.naturalWidth, expected, 'naturalWidth'); + assert_equals(img.naturalHeight, expected, 'naturalHeight'); + }, img.outerHTML); + }); + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/current-pixel-density/error.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/current-pixel-density/error.html new file mode 100644 index 000000000..5e328b5e2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/current-pixel-density/error.html @@ -0,0 +1,31 @@ +<!doctype html> +<title>img current pixel density error</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<img id=ref src="404" alt="testing"> +<img srcset="404" alt="testing"> +<img srcset="404 0.5x" alt="testing"> +<img srcset="404 2x" alt="testing"> +<img srcset="404 100w" alt="testing"> +<img srcset="404 100w" sizes="500px" alt="testing"> +<picture><img src="404 100w" sizes="500px" alt="testing"></picture> +<script> +setup({explicit_done:true}); +onload = function() { + var ref = document.getElementById("ref"); + var expected_width = ref.width; + var expected_height = ref.height; + [].forEach.call(document.images, function(img) { + test(function() { + assert_not_equals(expected_width, 0, 'expected_width'); + assert_not_equals(expected_height, 0, 'expected_height'); + assert_equals(img.width, expected_width, 'width'); + assert_equals(img.height, expected_height, 'height'); + assert_equals(img.naturalWidth, 0, 'naturalWidth'); + assert_equals(img.naturalHeight, 0, 'naturalHeight'); + }, img.outerHTML); + }); + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/document-base-url-ref.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/document-base-url-ref.html new file mode 100644 index 000000000..6e55b21ff --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/document-base-url-ref.html @@ -0,0 +1,5 @@ +<!DOCTYPE HTML> +<meta charset="utf-8"> +<title>Document base URL img test</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-img-element" /> +<img src="resources/cat.jpg" alt="cat"> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/document-base-url.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/document-base-url.html new file mode 100644 index 000000000..074209cc0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/document-base-url.html @@ -0,0 +1,7 @@ +<!DOCTYPE HTML> +<meta charset="utf-8"> +<title>Document base URL img test</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-img-element" /> +<link rel="match" href="document-base-url-ref.html"> +<base href="resources/" /> +<img src="cat.jpg" alt="cat"> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/environment-changes/iframed.sub.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/environment-changes/iframed.sub.html new file mode 100644 index 000000000..0f7ab9ae2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/environment-changes/iframed.sub.html @@ -0,0 +1,78 @@ +<!doctype html> + +<img +data-desc="img (no src)" +data-narrow="" +data-wide="" +data-no-change> + +<img src="" +data-desc="img (empty src)" +data-narrow="" +data-wide="" +data-no-change> + +<img src="/images/broken.png?30-{{GET[id]}}" +data-desc="img (src only) broken image" +data-narrow="/images/broken.png?30-{{GET[id]}}" +data-wide="/images/broken.png?30-{{GET[id]}}" +data-no-change> + +<img src="/images/green-1x1.png?40-{{GET[id]}}" +data-desc="img (src only) valid image" +data-narrow="/images/green-1x1.png?40-{{GET[id]}}" +data-wide="/images/green-1x1.png?40-{{GET[id]}}" +data-no-change> + +<img srcset="/images/broken.png?50-{{GET[id]}}" +data-desc="img (srcset 1 cand) broken image" +data-narrow="/images/broken.png?50-{{GET[id]}}" +data-wide="/images/broken.png?50-{{GET[id]}}" +data-no-change> + +<img srcset="/images/green-1x1.png?60-{{GET[id]}}" +data-desc="img (srcset 1 cand) valid image" +data-narrow="/images/green-1x1.png?60-{{GET[id]}}" +data-wide="/images/green-1x1.png?60-{{GET[id]}}" +data-no-change> + +<picture> +<source media="(max-width:500px)" srcset="/images/broken.png?70-{{GET[id]}}"> +<img src="/images/broken.png?71-{{GET[id]}}" +data-desc="picture: source (max-width:500px) broken image, img broken image" +data-narrow="/images/broken.png?70-{{GET[id]}}" +data-wide="/images/broken.png?71-{{GET[id]}}"> +</picture> + +<picture> +<source media="(max-width:500px)" srcset="/images/broken.png?80-{{GET[id]}}"> +<img src="/images/green-2x2.png?81-{{GET[id]}}" +data-desc="picture: source (max-width:500px) broken image, img valid image" +data-narrow="/images/broken.png?80-{{GET[id]}}" +data-wide="/images/green-2x2.png?81-{{GET[id]}}"> +</picture> + +<picture> +<source media="(max-width:500px)" srcset="/images/green-1x1.png?90-{{GET[id]}}"> +<img src="/images/broken.png?91-{{GET[id]}}" +data-desc="picture: source (max-width:500px) valid image, img broken image" +data-narrow="/images/green-1x1.png?90-{{GET[id]}}" +data-wide="/images/broken.png?91-{{GET[id]}}"> +</picture> + +<picture> +<source media="(max-width:500px)" srcset="/images/green-1x1.png?100-{{GET[id]}}"> +<img src="/images/green-2x2.png?101-{{GET[id]}}" +data-desc="picture: source (max-width:500px) valid image, img valid image" +data-narrow="/images/green-1x1.png?100-{{GET[id]}}" +data-wide="/images/green-2x2.png?101-{{GET[id]}}"> +</picture> + +<picture> +<source media="(max-width:500px)" srcset="/images/green-1x1.png?110-{{GET[id]}}"> +<img src="/images/green-1x1.png?110-{{GET[id]}}" +data-desc="picture: same URL in source (max-width:500px) and img" +data-narrow="/images/green-1x1.png?110-{{GET[id]}}" +data-wide="/images/green-1x1.png?110-{{GET[id]}}" +data-no-change> +</picture> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html new file mode 100644 index 000000000..21624712c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html @@ -0,0 +1,65 @@ +<!doctype html> +<title>img viewport change</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/utils.js"></script> +<style> +.narrow { width:50px } +.wide { width:1000px } +</style> +<div id=log></div> +<script> +setup({explicit_done:true}); + +function resolve(url) { + if (url === "") { + return url; + } + var a = document.createElement('a'); + a.href = url; + return a.href; +} + +function insertIframe(className) { + var iframe = document.createElement('iframe'); + iframe.className = className; + iframe.src = 'iframed.sub.html?id=' + token(); + document.body.appendChild(iframe); +} +insertIframe('narrow'); +insertIframe('wide'); + +var start_date = new Date(); + +onload = function() { + var load_time = new Date() - start_date; + var iframes = document.getElementsByTagName('iframe'); + [].forEach.call(iframes, function(iframe) { + [].forEach.call(iframe.contentDocument.images, function(img) { + var expected = {wide:resolve(img.dataset.wide), narrow:resolve(img.dataset.narrow)}; + var current = iframe.className; + var next = current === 'wide' ? 'narrow' : 'wide'; + var expect_change = expected[next].indexOf('broken.png') !== 0 && !('noChange' in img.dataset); + + test(function() { + assert_equals(img.currentSrc, expected[current]); + }, img.dataset.desc + ', onload, ' + current); + + async_test(function() { + img.onload = this.unreached_func('Got unexpected load event'); + img.onerror = this.unreached_func('Got unexpected error event'); + if (expect_change) { + img.onload = this.step_func_done(function() { + assert_equals(img.currentSrc, expected[next]); + }); + } else { + setTimeout(this.step_func_done(), 500 + load_time); + } + }, img.dataset.desc + ', resize to ' + next); + }); + iframe.classList.toggle('wide'); + iframe.classList.toggle('narrow'); + }); + done(); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image-1.jpg b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image-1.jpg Binary files differnew file mode 100644 index 000000000..2fb025560 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image-1.jpg diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image.png b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image.png Binary files differnew file mode 100644 index 000000000..d26878c9f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/img.complete.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/img.complete.html new file mode 100644 index 000000000..a34010aad --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/img.complete.html @@ -0,0 +1,82 @@ +<!DOCTYPE HTML> +<title>DOM img complete Test</title> +<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> +<link rel="author" title="Anselm Hannemann" href="http://anselm-hannemann.com/" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-img-complete" /> +<meta name="assert" content="Tests the complete status of the img-element"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<img id="imgTestTag"> +<img src="" id="imgTestTag2"> +<img id="imgTestTag3" style="width: 80px; height:auto;"> +<img id="imgTestTag4"> + +<script> + var imageInstance = document.createElement('img'); + imageInstance.style.display = 'none'; + + document.body.appendChild(imageInstance); +</script> + +<div id="log"></div> +<script> + test(function() { + assert_true(document.getElementById("imgTestTag").complete); + }, "img src omitted"); + + test(function() { + assert_true(document.getElementById("imgTestTag2").complete); + }, "img src empty"); + + // test if set to true after img is completely available + var t = async_test("async src complete test"); + + t.step(function(){ + document.getElementById("imgTestTag3").src = '3.jpg?nocache=' + Math.random(); + + //test if img.complete is set to false if src is changed + assert_false(document.getElementById("imgTestTag3").complete, "src changed, should be set to false") + }); + + document.getElementById("imgTestTag3").onload = t.step_func(function(){ + assert_true(document.getElementById("imgTestTag3").complete); + t.done(); + }); + + // https://html.spec.whatwg.org/multipage/multipage/embedded-content-1.html#update-the-image-data + // says to "await a stable state" before fetching so we use a separate <script> + imageInstance.src = 'image-1.jpg?pipe=trickle(d1)&nocache=' + Math.random(); // make sure the image isn't in cache +</script> +<script> + // test: The final task that is queued by the networking task source once the resource has been fetched has been queued, but has not yet been run, and the img element is not in the broken state + async_test(function(t) { + assert_false(imageInstance.complete, "imageInstance.complete should be false"); + var startTime = Date.now(); + while (true) { + if (Date.now() - startTime > 2000) + assert_unreached('.complete didn\'t change to true'); + if (imageInstance.complete === true) break; + } + t.done(); + }, + 'IDL attribute complete returns true when image resource has been fetched but not run yet & image is not in broken state'); + + // test if broken img does not pass + var t2 = async_test("async src broken test"); + var img4 = document.getElementById("imgTestTag4"); + + t2.step( + function(){ + img4.src = 'brokenimg.jpg'; + + //test if img.complete is set to false if src is changed + assert_false(img4.complete, "src changed to broken img, should be set to false"); + }); + + img4.onload = img4.onerror = t2.step_func(function(event){ + assert_equals(event.type, "error"); + assert_true(img4.complete); + t2.done(); + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/invalid-src.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/invalid-src.html new file mode 100644 index 000000000..f1fbe34c5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/invalid-src.html @@ -0,0 +1,42 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Loading a non-parsing URL as an image should silently fail; triggering appropriate events</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<img id=brokenurl /> +<img id=emptysrc /> +<script> +async_test(function(t) { + var img = document.getElementById("brokenurl"); + img.src = "http://also a broken url"; + var errorevent = false; + + // The errors should be queued in the event loop, so they should only trigger + // after this block of code finishes, not during the img.src setter itself + img.addEventListener('error', t.step_func(function(){errorevent = true;})); + img.addEventListener('loadend', t.step_func_done(function() { + assert_true(errorevent, "error event fired"); + })); +}, 'src="http://also a broken url"'); + +async_test(function(t) { + var img = document.getElementById("emptysrc"); + img.src = ""; + var loadendevent = false; + + // Setting src to empty string triggers only error event. + // The errors should be queued in the event loop, so they should only trigger + // after this block of code finishes, not during the img.src setter itself + img.addEventListener('error', t.step_func(function() { + // Queue this check in the event loop to check there is no loadend event + // fired. + t.step_timeout(t.step_func_done(function() { + assert_false(loadendevent, "loadend event should not fired"); + }), 0) + })); + img.addEventListener('loadend', t.step_func(function() { + loadendevent = true; + })); +}, 'src=""'); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/nonexistent-image.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/nonexistent-image.html new file mode 100644 index 000000000..f58569ede --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/nonexistent-image.html @@ -0,0 +1,21 @@ +<!DOCTYPE HTML> +<meta charset="utf-8"> +<title>Loading an nonexisting image should fail; triggering appropriate events</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<img> + +<script> + async_test(function(t) { + var img = document.querySelector("img"); + img.onload = this.step_func_done(function() { + assert_unreached("image.onload() was not supposed to be called"); + }); + img.onerror = this.step_func_done(function(e) { + assert_equals(e.type, "error", "image.onerror() called"); + t.done(); + }); + img.src = "404"; + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/relevant-mutations.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/relevant-mutations.html new file mode 100644 index 000000000..c8e09e8d0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/relevant-mutations.html @@ -0,0 +1,416 @@ +<!doctype html> +<title>img relevant mutations</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> + +<!-- should invoke update the image data --> + +<img data-desc="src set"> +<img src="/images/green-2x2.png" data-desc="src changed"> +<img src="/images/green-2x2.png" data-desc="src removed"> + +<img data-desc="srcset set"> +<img srcset="/images/green-2x2.png" data-desc="srcset changed"> +<img srcset="/images/green-2x2.png" data-desc="srcset removed"> + +<img data-desc="sizes set"> +<img sizes="" data-desc="sizes changed"> +<img sizes="" data-desc="sizes removed"> + +<img src="/images/green-2x2.png" data-desc="src set to same value"> + +<img data-desc="crossorigin absent to empty"> +<img data-desc="crossorigin absent to anonymous"> +<img data-desc="crossorigin absent to use-credentials"> +<img crossorigin data-desc="crossorigin empty to absent"> +<img crossorigin data-desc="crossorigin empty to use-credentials"> +<img crossorigin=anonymous data-desc="crossorigin anonymous to absent"> +<img crossorigin=anonymous data-desc="crossorigin anonymous to use-credentials"> +<img crossorigin=use-credentials data-desc="crossorigin use-credentials to absent"> +<img crossorigin=use-credentials data-desc="crossorigin use-credentials to empty"> +<img crossorigin=use-credentials data-desc="crossorigin use-credentials to anonymous"> + +<img src="/images/green-2x2.png" data-desc="inserted into picture"><picture></picture> + +<picture><img src="/images/green-2x2.png" data-desc="removed from picture"></picture> + +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, previous source inserted"></picture> + +<picture><source><img src="/images/green-2x2.png" data-desc="parent is picture, previous source removed"></picture> + +<picture><source><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has srcset set"></picture> +<picture><source srcset=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has srcset changed"></picture> +<picture><source srcset=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has srcset removed"></picture> + +<picture><source><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has sizes set"></picture> +<picture><source sizes=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has sizes changed"></picture> +<picture><source sizes=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has sizes removed"></picture> + +<picture><source><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has media set"></picture> +<picture><source media=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has media changed"></picture> +<picture><source media=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has media removed"></picture> + +<picture><source><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has type set"></picture> +<picture><source type=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has type changed"></picture> +<picture><source type=""><img src="/images/green-2x2.png" data-desc="parent is picture, previous source has type removed"></picture> + +<!-- should not invoke update the image data --> + +<img srcset="/images/green-2x2.png" data-desc="srcset is set to same value"> +<img srcset="/images/green-2x2.png" sizes data-desc="sizes is set to same value"> + +<img src="/images/green-2x2.png" data-desc="crossorigin state not changed: absent, removeAttribute"> +<img src="/images/green-2x2.png" crossorigin data-desc="crossorigin state not changed: empty to anonymous"> +<img src="/images/green-2x2.png" crossorigin=anonymous data-desc="crossorigin state not changed: anonymous to foobar"> +<img src="/images/green-2x2.png" crossorigin=use-credentials data-desc="crossorigin state not changed: use-credentials to USE-CREDENTIALS"> + +<img src="/images/green-2x2.png" data-desc="inserted into picture ancestor"><picture><span></span></picture> +<picture><span><img src="/images/green-2x2.png" data-desc="removed from picture ancestor"></span></picture> + +<picture><span><img src="/images/green-2x2.png" data-desc="ancestor picture has a source inserted"></span></picture> +<picture><source><span><img src="/images/green-2x2.png" data-desc="ancestor picture has a source removed"></span></picture> + +<picture><span><img src="/images/green-2x2.png" data-desc="ancestor picture; previous sibling source inserted"></span></picture> +<picture><span><source><img src="/images/green-2x2.png" data-desc="ancestor picture; previous sibling source removed"></span></picture> + +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following sibling source inserted"></picture> +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following sibling source removed"><source></picture> + +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following sibling source has srcset set"><source></picture> + +<img src="/images/green-2x2.png" data-desc="media on img set"> +<img src="/images/green-2x2.png" data-desc="type on img set"> +<img src="/images/green-2x2.png" data-desc="class on img set"> +<img src="/images/green-2x2.png" data-desc="alt on img set"> + +<picture><source><img src="/images/green-2x2.png" data-desc="src on previous sibling source set"></picture> +<picture><source><img src="/images/green-2x2.png" data-desc="class on previous sibling source set"></picture> + +<img src="/images/green-2x2.png" data-desc="inserted/removed children of img"> + +<picture><img src="/images/green-2x2.png" data-desc="picture is inserted; img has src"></picture><span></span> +<picture><img srcset="/images/green-2x2.png" data-desc="picture is inserted; img has srcset"></picture><span></span> +<picture><source srcset="/images/green-2x2.png"><img src="/images/green-2x2.png" data-desc="picture is inserted; img has previous sibling source"></picture><span></span> +<picture><img src="/images/green-2x2.png" data-desc="picture is inserted; img has following sibling source"><source srcset="/images/green-2x2.png"></picture><span></span> + +<picture><img src="/images/green-2x2.png" data-desc="picture is removed; img has src"></picture> +<picture><img srcset="/images/green-2x2.png" data-desc="picture is removed; img has srcset"></picture> +<picture><source srcset="/images/green-2x2.png"><img src="/images/green-2x2.png" data-desc="picture is removed; img has previous sibling source"></picture> +<picture><img src="/images/green-2x2.png" data-desc="picture is removed; img has following sibling source"><source srcset="/images/green-2x2.png"></picture> + +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following img inserted"></picture> +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following img removed"><img></picture> +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following img has src set"><img></picture> +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following img has srcset set"><img></picture> +<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following img has sizes set"><img></picture> + + +<script> +setup({explicit_done:true}); + +function t(desc, func, expect) { + async_test(function() { + var img = document.querySelector('[data-desc="' + desc + '"]'); + img.onload = img.onerror = this.unreached_func('update the image data was run'); + if (expect == 'timeout') { + setTimeout(this.step_func_done(), 1000); + } else { + img['on' + expect] = this.step_func_done(function() {}); + } + func.call(this, img); + }, desc); +} + +onload = function() { + + t('src set', function(img) { + img.src = '/images/green-2x2.png'; + }, 'load'); + + t('src changed', function(img) { + img.src = '/images/green-2x2.png '; + }, 'load'); + + t('src removed', function(img) { + img.removeAttribute('src'); + }, 'timeout'); + + t('srcset set', function(img) { + img.srcset = '/images/green-2x2.png'; + }, 'load'); + + t('srcset changed', function(img) { + img.srcset = '/images/green-2x2.png '; + }, 'load'); + + t('srcset removed', function(img) { + img.removeAttribute('srcset'); + }, 'timeout'); + + t('sizes set', function(img) { + img.sizes = ''; + }, 'timeout'); + + t('sizes changed', function(img) { + img.sizes = ' '; + }, 'timeout'); + + t('sizes removed', function(img) { + img.removeAttribute('sizes'); + }, 'timeout'); + + t('src set to same value', function(img) { + img.src = '/images/green-2x2.png'; + }, 'load'); + + t('crossorigin absent to empty', function(img) { + img.crossOrigin = ''; + }, 'timeout'); + + t('crossorigin absent to anonymous', function(img) { + img.crossOrigin = 'anonymous'; + }, 'timeout'); + + t('crossorigin absent to use-credentials', function(img) { + img.crossOrigin = 'use-credentials'; + }, 'timeout'); + + t('crossorigin empty to absent', function(img) { + img.removeAttribute('crossorigin'); + }, 'timeout'); + + t('crossorigin empty to use-credentials', function(img) { + img.crossOrigin = 'use-credentials'; + }, 'timeout'); + + t('crossorigin anonymous to absent', function(img) { + img.removeAttribute('crossorigin'); + }, 'timeout'); + + t('crossorigin anonymous to use-credentials', function(img) { + img.crossOrigin = 'use-credentials'; + }, 'timeout'); + + t('crossorigin use-credentials to absent', function(img) { + img.removeAttribute('crossorigin'); + }, 'timeout'); + + t('crossorigin use-credentials to empty', function(img) { + img.crossOrigin = ''; + }, 'timeout'); + + t('crossorigin use-credentials to anonymous', function(img) { + img.crossOrigin = 'anonymous'; + }, 'timeout'); + + t('inserted into picture', function(img) { + img.nextSibling.appendChild(img); + }, 'load'); + + t('removed from picture', function(img) { + img.parentNode.removeChild(img); + }, 'load'); + + t('parent is picture, previous source inserted', function(img) { + img.parentNode.insertBefore(document.createElement('source'), img); + }, 'load'); + + t('parent is picture, previous source removed', function(img) { + img.parentNode.removeChild(img.previousSibling); + }, 'load'); + + t('parent is picture, previous source has srcset set', function(img) { + img.previousSibling.srcset = ''; + }, 'load'); + + t('parent is picture, previous source has srcset changed', function(img) { + img.previousSibling.srcset = ' '; + }, 'load'); + + t('parent is picture, previous source has srcset removed', function(img) { + img.previousSibling.removeAttribute('srcset'); + }, 'load'); + + t('parent is picture, previous source has sizes set', function(img) { + img.previousSibling.sizes = ''; + }, 'load'); + + t('parent is picture, previous source has sizes changed', function(img) { + img.previousSibling.sizes = ' '; + }, 'load'); + + t('parent is picture, previous source has sizes removed', function(img) { + img.previousSibling.removeAttribute('sizes'); + }, 'load'); + + t('parent is picture, previous source has media set', function(img) { + img.previousSibling.media = ''; + }, 'load'); + + t('parent is picture, previous source has media changed', function(img) { + img.previousSibling.media = ' '; + }, 'load'); + + t('parent is picture, previous source has media removed', function(img) { + img.previousSibling.removeAttribute('media'); + }, 'load'); + + t('parent is picture, previous source has type set', function(img) { + img.previousSibling.type = ''; + }, 'load'); + + t('parent is picture, previous source has type changed', function(img) { + img.previousSibling.type = ' '; + }, 'load'); + + t('parent is picture, previous source has type removed', function(img) { + img.previousSibling.removeAttribute('type'); + }, 'load'); + + t('srcset is set to same value', function(img) { + img.srcset = "/images/green-2x2.png"; + }, 'timeout'); + + t('sizes is set to same value', function(img) { + img.sizes = ''; + }, 'timeout'); + + t('crossorigin state not changed: absent, removeAttribute', function(img) { + img.removeAttribute('crossorigin'); + }, 'timeout'); + + t('crossorigin state not changed: empty to anonymous', function(img) { + img.crossOrigin = 'anonymous'; + }, 'timeout'); + + t('crossorigin state not changed: anonymous to foobar', function(img) { + img.crossOrigin = 'foobar'; + }, 'timeout'); + + t('crossorigin state not changed: use-credentials to USE-CREDENTIALS', function(img) { + img.crossOrigin = 'USE-CREDENTIALS'; + }, 'timeout'); + + t('inserted into picture ancestor', function(img) { + img.nextSibling.firstChild.appendChild(img); + }, 'timeout'); + + t('removed from picture ancestor', function(img) { + img.parentNode.removeChild(img); + }, 'timeout'); + + t('ancestor picture has a source inserted', function(img) { + img.parentNode.parentNode.insertBefore(document.createElement('source'), img.parentNode); + }, 'timeout'); + + t('ancestor picture has a source removed', function(img) { + img.parentNode.parentNode.removeChild(img.parentNode.previousSibling); + }, 'timeout'); + + t('ancestor picture; previous sibling source inserted', function(img) { + img.parentNode.insertBefore(document.createElement('source'), img); + }, 'timeout'); + + t('ancestor picture; previous sibling source removed', function(img) { + img.parentNode.removeChild(img.previousSibling); + }, 'timeout'); + + t('parent is picture, following sibling source inserted', function(img) { + img.parentNode.appendChild(document.createElement('source')); + }, 'timeout'); + + t('parent is picture, following sibling source removed', function(img) { + img.parentNode.removeChild(img.nextSibling); + }, 'timeout'); + + t('parent is picture, following sibling source has srcset set', function(img) { + img.nextSibling.srcset = ''; + }, 'timeout'); + + t('media on img set', function(img) { + img.setAttribute('media', ''); + }, 'timeout'); + + t('type on img set', function(img) { + img.setAttribute('type', ''); + }, 'timeout'); + + t('class on img set', function(img) { + img.className = ''; + }, 'timeout'); + + t('alt on img set', function(img) { + img.alt = ''; + }, 'timeout'); + + t('src on previous sibling source set', function(img) { + img.previousSibling.setAttribute('src', ''); + }, 'timeout'); + + t('class on previous sibling source set', function(img) { + img.previousSibling.className = ''; + }, 'timeout'); + + t('inserted/removed children of img', function(img) { + img.appendChild(document.createElement('source')); + setTimeout(this.step_func(function() { + img.removeChild(img.firstChild); + }), 0); + }, 'timeout'); + + t('picture is inserted; img has src', function(img) { + img.parentNode.nextSibling.appendChild(img.parentNode); + }, 'timeout'); + + t('picture is inserted; img has srcset', function(img) { + img.parentNode.nextSibling.appendChild(img.parentNode); + }, 'timeout'); + + t('picture is inserted; img has previous sibling source', function(img) { + img.parentNode.nextSibling.appendChild(img.parentNode); + }, 'timeout'); + + t('picture is inserted; img has following sibling source', function(img) { + img.parentNode.nextSibling.appendChild(img.parentNode); + }, 'timeout'); + + t('picture is removed; img has src', function(img) { + img.parentNode.parentNode.removeChild(img.parentNode); + }, 'timeout'); + + t('picture is removed; img has srcset', function(img) { + img.parentNode.parentNode.removeChild(img.parentNode); + }, 'timeout'); + + t('picture is removed; img has previous sibling source', function(img) { + img.parentNode.parentNode.removeChild(img.parentNode); + }, 'timeout'); + + t('picture is removed; img has following sibling source', function(img) { + img.parentNode.parentNode.removeChild(img.parentNode); + }, 'timeout'); + + t('parent is picture, following img inserted', function(img) { + img.parentNode.appendChild(document.createElement('img')); + }, 'timeout'); + + t('parent is picture, following img removed', function(img) { + img.parentNode.removeChild(img.nextSibling); + }, 'timeout'); + + t('parent is picture, following img has src set', function(img) { + img.nextSibling.src = ''; + }, 'timeout'); + + t('parent is picture, following img has srcset set', function(img) { + img.nextSibling.srcset = ''; + }, 'timeout'); + + t('parent is picture, following img has sizes set', function(img) { + img.nextSibling.sizes = ''; + }, 'timeout'); + + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/cat.jpg b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/cat.jpg Binary files differnew file mode 100644 index 000000000..a4f14f54d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/cat.jpg diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute.html new file mode 100644 index 000000000..bd2045420 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute.html @@ -0,0 +1,42 @@ +<!doctype html> +<title>img parse a sizes attribute</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<iframe data-desc="standards mode" style="width:1000px; height:1000px" src="sizes-iframed.sub.html?doctype=doctype%20html&style="></iframe> +<iframe data-desc="quirks mode" style="width:1000px; height:1000px" src="sizes-iframed.sub.html?doctype=----&style="></iframe> +<iframe data-desc="display:none" style="width:1000px; height:1000px" src="sizes-iframed.sub.html?doctype=doctype%20html&style=display:none"></iframe> +<iframe data-desc="width:1000px" style="width:1000px; height:1000px" src="sizes-iframed.sub.html?doctype=doctype%20html&style=width:1000px%3B%20height:16px"></iframe> +<script> +setup({explicit_done:true}); + +function check(p, iframe) { + var current = p.firstElementChild; + var ref_sizes = current.getAttribute('sizes'); + var expect = p.firstElementChild.currentSrc; + if (expect) { + expect = expect.split('?')[0]; + } + while (current = current.nextElementSibling) { + test(function() { + if (expect === '' || expect === null || expect === undefined) { + assert_unreached('ref currentSrc was ' + format_value(expect)); + } + var got = current.currentSrc; + assert_greater_than(got.indexOf('?'), -1, 'expected a "?" in currentSrc'); + got = got.split('?')[0]; + assert_equals(got, expect); + }, current.outerHTML + ' ref sizes=' + format_value(ref_sizes) + ' (' + iframe.getAttribute('data-desc') + ')'); + } +} + +onload = function() { + [].forEach.call(document.querySelectorAll('iframe'), function(iframe) { + [].forEach.call(iframe.contentDocument.querySelectorAll('p'), function(p) { + check(p, iframe); + }); + }); + done(); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/sizes/sizes-iframed.sub.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/sizes/sizes-iframed.sub.html new file mode 100644 index 000000000..925bb4699 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/sizes/sizes-iframed.sub.html @@ -0,0 +1,178 @@ +<!{{GET[doctype]}}> +<style> img { {{GET[style]}} } </style> +<!-- First <img> in a <p> is the reference. The following <img>s should be equivalent --> +<!-- default is 100vw, not 300px --> +<p> +<img srcset='/images/green-1x1.png?a1 300w, /images/green-16x16.png?a1 301w' sizes='100vw'> +<img srcset='/images/green-1x1.png?a2 300w, /images/green-16x16.png?a2 301w'> +<p> +<img srcset='/images/green-1x1.png?b1 450w, /images/green-16x16.png?b1 451w' sizes='100vw'> +<img srcset='/images/green-1x1.png?b2 450w, /images/green-16x16.png?b2 451w'> +<p> +<img srcset='/images/green-1x1.png?c1 600w, /images/green-16x16.png?c1 601w' sizes='100vw'> +<img srcset='/images/green-1x1.png?c2 600w, /images/green-16x16.png?c2 601w'> +<p> +<img srcset='/images/green-1x1.png?d1 900w, /images/green-16x16.png?d1 901w' sizes='100vw'> +<img srcset='/images/green-1x1.png?d2 900w, /images/green-16x16.png?d2 901w'> + +<p> +<img srcset='/images/green-1x1.png?e1 50w, /images/green-16x16.png?e1 51w' sizes='1px'> +<img srcset='/images/green-1x1.png?e2 50w, /images/green-16x16.png?e2 51w' sizes='0'> +<img srcset='/images/green-1x1.png?e3 50w, /images/green-16x16.png?e3 51w' sizes='-0'> +<img srcset='/images/green-1x1.png?e4 50w, /images/green-16x16.png?e4 51w' sizes='+0'> +<img srcset='/images/green-1x1.png?e5 50w, /images/green-16x16.png?e5 51w' sizes='+1px'> +<img srcset='/images/green-1x1.png?e6 50w, /images/green-16x16.png?e6 51w' sizes='.1px'> +<img srcset='/images/green-1x1.png?e7 50w, /images/green-16x16.png?e7 51w' sizes='0.1em'> +<img srcset='/images/green-1x1.png?e8 50w, /images/green-16x16.png?e8 51w' sizes='0.1ex'> +<img srcset='/images/green-1x1.png?e9 50w, /images/green-16x16.png?e9 51w' sizes='0.1ch'> +<img srcset='/images/green-1x1.png?e10 50w, /images/green-16x16.png?e10 51w' sizes='0.1rem'> +<img srcset='/images/green-1x1.png?e11 50w, /images/green-16x16.png?e11 51w' sizes='0.1vw'> +<img srcset='/images/green-1x1.png?e12 50w, /images/green-16x16.png?e12 51w' sizes='0.1vh'> +<img srcset='/images/green-1x1.png?e13 50w, /images/green-16x16.png?e13 51w' sizes='0.1vmin'> +<img srcset='/images/green-1x1.png?e14 50w, /images/green-16x16.png?e14 51w' sizes='0.1vmax'> +<img srcset='/images/green-1x1.png?e15 50w, /images/green-16x16.png?e15 51w' sizes='0.1cm'> +<img srcset='/images/green-1x1.png?e16 50w, /images/green-16x16.png?e16 51w' sizes='1mm'> +<img srcset='/images/green-1x1.png?e17 50w, /images/green-16x16.png?e17 51w' sizes='1q'> +<img srcset='/images/green-1x1.png?e18 50w, /images/green-16x16.png?e18 51w' sizes='0.01in'> +<img srcset='/images/green-1x1.png?e19 50w, /images/green-16x16.png?e19 51w' sizes='0.1pc'> +<img srcset='/images/green-1x1.png?e20 50w, /images/green-16x16.png?e20 51w' sizes='0.1pt'> +<img srcset='/images/green-1x1.png?e21 50w, /images/green-16x16.png?e21 51w' sizes='/* */1px/* */'> +<img srcset='/images/green-1x1.png?e22 50w, /images/green-16x16.png?e22 51w' sizes=' /**/ /**/ 1px /**/ /**/ '> +<img srcset='/images/green-1x1.png?e23 50w, /images/green-16x16.png?e23 51w' sizes='(),1px'> +<img srcset='/images/green-1x1.png?e24 50w, /images/green-16x16.png?e24 51w' sizes='x(),1px'> +<img srcset='/images/green-1x1.png?e25 50w, /images/green-16x16.png?e25 51w' sizes='{},1px'> +<img srcset='/images/green-1x1.png?e26 50w, /images/green-16x16.png?e26 51w' sizes='[],1px'> +<img srcset='/images/green-1x1.png?e27 50w, /images/green-16x16.png?e27 51w' sizes='1px,('> +<img srcset='/images/green-1x1.png?e28 50w, /images/green-16x16.png?e28 51w' sizes='1px,x('> +<img srcset='/images/green-1x1.png?e29 50w, /images/green-16x16.png?e29 51w' sizes='1px,{'> +<img srcset='/images/green-1x1.png?e30 50w, /images/green-16x16.png?e30 51w' sizes='1px,['> +<img srcset='/images/green-1x1.png?e31 50w, /images/green-16x16.png?e31 51w' sizes='\(,1px'> +<img srcset='/images/green-1x1.png?e32 50w, /images/green-16x16.png?e32 51w' sizes='x\(,1px'> +<img srcset='/images/green-1x1.png?e33 50w, /images/green-16x16.png?e33 51w' sizes='\{,1px'> +<img srcset='/images/green-1x1.png?e34 50w, /images/green-16x16.png?e34 51w' sizes='\[,1px'> +<img srcset='/images/green-1x1.png?e35 50w, /images/green-16x16.png?e35 51w' sizes='1\p\x'> +<img srcset='/images/green-1x1.png?e36 50w, /images/green-16x16.png?e36 51w' sizes='calc(1px)'> +<img srcset='/images/green-1x1.png?e37 50w, /images/green-16x16.png?e37 51w' sizes='(min-width:0) calc(1px)'> +<img srcset='/images/green-1x1.png?e38 50w, /images/green-16x16.png?e38 51w' sizes='(min-width:calc(0)) 1px'> +<img srcset='/images/green-1x1.png?e39 50w, /images/green-16x16.png?e39 51w' sizes='(min-width:0) 1px, 100vw'> +<img srcset='/images/green-1x1.png?e40 50w, /images/green-16x16.png?e40 51w' sizes='(min-width:0) 1px, (min-width:0) 100vw, 100vw'> +<img srcset='/images/green-1x1.png?e41 50w, /images/green-16x16.png?e41 51w' sizes='(min-width:0) 1px'> +<img srcset='/images/green-1x1.png?e42 50w, /images/green-16x16.png?e42 51w' sizes='not (min-width:0) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e43 50w, /images/green-16x16.png?e43 51w' sizes='(min-width:unknown-mf-value) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e44 50w, /images/green-16x16.png?e44 51w' sizes='not (min-width:unknown-mf-value) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e45 50w, /images/green-16x16.png?e45 51w' sizes='(min-width:-1px) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e46 50w, /images/green-16x16.png?e46 51w' sizes='not (min-width:-1px) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e47 50w, /images/green-16x16.png?e47 51w' sizes='(unknown-mf-name) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e48 50w, /images/green-16x16.png?e48 51w' sizes='not (unknown-mf-name) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e49 50w, /images/green-16x16.png?e49 51w' sizes='(unknown "general-enclosed") 100vw, 1px'> +<img srcset='/images/green-1x1.png?e50 50w, /images/green-16x16.png?e50 51w' sizes='not (unknown "general-enclosed") 100vw, 1px'> +<img srcset='/images/green-1x1.png?e51 50w, /images/green-16x16.png?e51 51w' sizes='unknown-general-enclosed(foo) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e52 50w, /images/green-16x16.png?e52 51w' sizes='not unknown-general-enclosed(foo) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e53 50w, /images/green-16x16.png?e53 51w' sizes='print 100vw, 1px'> +<img srcset='/images/green-1x1.png?e54 50w, /images/green-16x16.png?e54 51w' sizes='not print 100vw, 1px'> +<img srcset='/images/green-1x1.png?e55 50w, /images/green-16x16.png?e55 51w' sizes='unknown-media-type 100vw, 1px'> +<img srcset='/images/green-1x1.png?e56 50w, /images/green-16x16.png?e56 51w' sizes='not unknown-media-type 100vw, 1px'> +<img srcset='/images/green-1x1.png?e57 50w, /images/green-16x16.png?e57 51w' sizes='(min-width:0) or (min-width:0) 1px'> +<img srcset='/images/green-1x1.png?e58 50w, /images/green-16x16.png?e58 51w' sizes='(min-width:0) or (unknown-mf-name) 1px'> +<img srcset='/images/green-1x1.png?e59 50w, /images/green-16x16.png?e59 51w' sizes='(min-width:0) or (min-width:unknown-mf-value) 1px'> +<img srcset='/images/green-1x1.png?e60 50w, /images/green-16x16.png?e60 51w' sizes='(min-width:0) or (min-width:-1px) 1px'> +<img srcset='/images/green-1x1.png?e61 50w, /images/green-16x16.png?e61 51w' sizes='(min-width:0) or (unknown "general-enclosed") 1px'> +<img srcset='/images/green-1x1.png?e62 50w, /images/green-16x16.png?e62 51w' sizes='(min-width:0) or unknown-general-enclosed(foo) 1px'> +<img srcset='/images/green-1x1.png?e63 50w, /images/green-16x16.png?e63 51w' sizes='(min-width:0) or (!) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e64 50w, /images/green-16x16.png?e64 51w' sizes='(min-width:0) or unknown-media-type 100vw, 1px'> +<img srcset='/images/green-1x1.png?e65 50w, /images/green-16x16.png?e65 51w' sizes='(123) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e66 50w, /images/green-16x16.png?e66 51w' sizes='not (123) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e67 50w, /images/green-16x16.png?e67 51w' sizes='(!) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e68 50w, /images/green-16x16.png?e68 51w' sizes='not (!) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e69 50w, /images/green-16x16.png?e69 51w' sizes='! 100vw, 1px'> +<img srcset='/images/green-1x1.png?e70 50w, /images/green-16x16.png?e70 51w' sizes='not ! 100vw, 1px'> +<img srcset='/images/green-1x1.png?e71 50w, /images/green-16x16.png?e71 51w' sizes='(]) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e72 50w, /images/green-16x16.png?e72 51w' sizes='not (]) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e73 50w, /images/green-16x16.png?e73 51w' sizes='] 100vw, 1px'> +<img srcset='/images/green-1x1.png?e74 50w, /images/green-16x16.png?e74 51w' sizes='not ] 100vw, 1px'> +<img srcset='/images/green-1x1.png?e75 50w, /images/green-16x16.png?e75 51w' sizes='(}) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e76 50w, /images/green-16x16.png?e76 51w' sizes='not (}) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e77 50w, /images/green-16x16.png?e77 51w' sizes='} 100vw, 1px'> +<img srcset='/images/green-1x1.png?e78 50w, /images/green-16x16.png?e78 51w' sizes='not } 100vw, 1px'> +<img srcset='/images/green-1x1.png?e79 50w, /images/green-16x16.png?e79 51w' sizes=') 100vw, 1px'> +<img srcset='/images/green-1x1.png?e80 50w, /images/green-16x16.png?e80 51w' sizes='not ) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e81 50w, /images/green-16x16.png?e81 51w' sizes='(;) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e82 50w, /images/green-16x16.png?e82 51w' sizes='not (;) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e83 50w, /images/green-16x16.png?e83 51w' sizes='(.) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e84 50w, /images/green-16x16.png?e84 51w' sizes='not (.) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e85 50w, /images/green-16x16.png?e85 51w' sizes='; 100vw, 1px'> +<img srcset='/images/green-1x1.png?e86 50w, /images/green-16x16.png?e86 51w' sizes='not ; 100vw, 1px'> +<img srcset='/images/green-1x1.png?e87 50w, /images/green-16x16.png?e87 51w' sizes=', 1px'> +<img srcset='/images/green-1x1.png?e88 50w, /images/green-16x16.png?e88 51w' sizes='1px,'> +<img srcset='/images/green-1x1.png?e89 50w, /images/green-16x16.png?e89 51w' sizes='(min-width:0) 1px,'> +<img srcset='/images/green-1x1.png?e90 50w, /images/green-16x16.png?e90 51w' sizes='-0e-0px'> +<img srcset='/images/green-1x1.png?e91 50w, /images/green-16x16.png?e91 51w' sizes='+0.11e+01px'> +<img srcset='/images/green-1x1.png?e92 50w, /images/green-16x16.png?e92 51w' sizes='0.2e1px'> +<img srcset='/images/green-1x1.png?e93 50w, /images/green-16x16.png?e93 51w' sizes='0.3E1px'> +<img srcset='/images/green-1x1.png?e94 50w, /images/green-16x16.png?e94 51w' sizes='.4E1px'> +<img srcset='/images/green-1x1.png?e95 50w, /images/green-16x16.png?e95 51w' sizes='all 100vw, 1px'> +<img srcset='/images/green-1x1.png?e96 50w, /images/green-16x16.png?e96 51w' sizes='all and (min-width:0) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e97 50w, /images/green-16x16.png?e97 51w' sizes='min-width:0 100vw, 1px'> +<img srcset='/images/green-1x1.png?e98 50w, /images/green-16x16.png?e98 51w' sizes='1px, 100vw'> +<img srcset='/images/green-1x1.png?e99 50w, /images/green-16x16.png?e99 51w' sizes='1px, (min-width:0) 100vw'> +<img srcset='/images/green-1x1.png?e100 50w, /images/green-16x16.png?e100 51w' sizes='1px, foo bar'> +<img srcset='/images/green-1x1.png?e101 50w, /images/green-16x16.png?e101 51w' sizes='(min-width:0) 1px, foo bar'> +<img srcset='/images/green-1x1.png?e102 50w, /images/green-16x16.png?e102 51w' sizes='("grammar does not match") 100vw, 1px'> +<img srcset='/images/green-1x1.png?e103 50w, /images/green-16x16.png?e103 51w' sizes='not ("grammar does not match") 100vw, 1px'> +<img srcset='/images/green-1x1.png?e104 50w, /images/green-16x16.png?e104 51w' sizes='(unknown-general-enclosed !) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e105 50w, /images/green-16x16.png?e105 51w' sizes='not (unknown-general-enclosed !) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e106 50w, /images/green-16x16.png?e106 51w' sizes='(min-width:0) or (unknown-general-enclosed !) 1px'> +<img srcset='/images/green-1x1.png?e107 50w, /images/green-16x16.png?e107 51w' sizes='not ((min-width:0) or (unknown "general-enclosed")) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e108 50w, /images/green-16x16.png?e108 51w' sizes='(max-width:0) or (unknown-general-enclosed !) 100vw, 1px'> +<img srcset='/images/green-1x1.png?e109 50w, /images/green-16x16.png?e109 51w' sizes='not ((max-width:0) or (unknown "general-enclosed")) 100vw, 1px'> +<img srcset='/images/green-1x1.png?f48 50w, /images/green-16x16.png?f48 51w' sizes='calc(1px'> +<img srcset='/images/green-1x1.png?f49 50w, /images/green-16x16.png?f49 51w' sizes='(min-width:0) calc(1px'> + +<p> +<img srcset='/images/green-1x1.png?f1 50w, /images/green-16x16.png?f1 51w' sizes='100vw'> +<img srcset='/images/green-1x1.png?f2 50w, /images/green-16x16.png?f2 51w' sizes=''> +<img srcset='/images/green-1x1.png?f3 50w, /images/green-16x16.png?f3 51w' sizes=','> +<img srcset='/images/green-1x1.png?f4 50w, /images/green-16x16.png?f4 51w' sizes='-1px'> +<img srcset='/images/green-1x1.png?f5 50w, /images/green-16x16.png?f5 51w' sizes='1'> +<img srcset='/images/green-1x1.png?f6 50w, /images/green-16x16.png?f6 51w' sizes='0.1%'> +<img srcset='/images/green-1x1.png?f7 50w, /images/green-16x16.png?f7 51w' sizes='0.1deg'> +<img srcset='/images/green-1x1.png?f8 50w, /images/green-16x16.png?f8 51w' sizes='0.1grad'> +<img srcset='/images/green-1x1.png?f9 50w, /images/green-16x16.png?f9 51w' sizes='0.1rad'> +<img srcset='/images/green-1x1.png?f10 50w, /images/green-16x16.png?f10 51w' sizes='0.1turn'> +<img srcset='/images/green-1x1.png?f11 50w, /images/green-16x16.png?f11 51w' sizes='0.1s'> +<img srcset='/images/green-1x1.png?f12 50w, /images/green-16x16.png?f12 51w' sizes='0.1ms'> +<img srcset='/images/green-1x1.png?f13 50w, /images/green-16x16.png?f13 51w' sizes='0.1Hz'> +<img srcset='/images/green-1x1.png?f14 50w, /images/green-16x16.png?f14 51w' sizes='0.1kHz'> +<img srcset='/images/green-1x1.png?f15 50w, /images/green-16x16.png?f15 51w' sizes='0.1dpi'> +<img srcset='/images/green-1x1.png?f16 50w, /images/green-16x16.png?f16 51w' sizes='0.1dpcm'> +<img srcset='/images/green-1x1.png?f17 50w, /images/green-16x16.png?f17 51w' sizes='0.1dppx'> +<img srcset='/images/green-1x1.png?f18 50w, /images/green-16x16.png?f18 51w' data-foo='1px' sizes='attr(data-foo, length, 1px)'> +<img srcset='/images/green-1x1.png?f19 50w, /images/green-16x16.png?f19 51w' data-foo='1' sizes='attr(data-foo, px, 1px)'> +<img srcset='/images/green-1x1.png?f20 50w, /images/green-16x16.png?f20 51w' sizes='toggle(1px)'> +<img srcset='/images/green-1x1.png?f21 50w, /images/green-16x16.png?f21 51w' sizes='inherit'> +<img srcset='/images/green-1x1.png?f22 50w, /images/green-16x16.png?f22 51w' sizes='auto'> +<img srcset='/images/green-1x1.png?f23 50w, /images/green-16x16.png?f23 51w' sizes='initial'> +<img srcset='/images/green-1x1.png?f24 50w, /images/green-16x16.png?f24 51w' sizes='unset'> +<img srcset='/images/green-1x1.png?f25 50w, /images/green-16x16.png?f25 51w' sizes='default'> +<img srcset='/images/green-1x1.png?f26 50w, /images/green-16x16.png?f26 51w' sizes='1/* */px'> +<img srcset='/images/green-1x1.png?f27 50w, /images/green-16x16.png?f27 51w' sizes='1p/* */x'> +<img srcset='/images/green-1x1.png?f28 50w, /images/green-16x16.png?f28 51w' sizes='-/**/0'> +<img srcset='/images/green-1x1.png?f29 50w, /images/green-16x16.png?f29 51w' sizes='((),1px'> +<img srcset='/images/green-1x1.png?f30 50w, /images/green-16x16.png?f30 51w' sizes='x(x(),1px'> +<img srcset='/images/green-1x1.png?f31 50w, /images/green-16x16.png?f31 51w' sizes='{{},1px'> +<img srcset='/images/green-1x1.png?f32 50w, /images/green-16x16.png?f32 51w' sizes='[[],1px'> +<img srcset='/images/green-1x1.png?f33 50w, /images/green-16x16.png?f33 51w' sizes='1px !important'> +<img srcset='/images/green-1x1.png?f34 50w, /images/green-16x16.png?f34 51w' sizes='\1px'> +<img srcset='/images/green-1x1.png?f35 50w, /images/green-16x16.png?f35 51w' sizes='all 1px'> +<img srcset='/images/green-1x1.png?f36 50w, /images/green-16x16.png?f36 51w' sizes='all and (min-width:0) 1px'> +<img srcset='/images/green-1x1.png?f37 50w, /images/green-16x16.png?f37 51w' sizes='min-width:0 1px'> +<img srcset='/images/green-1x1.png?f38 50w, /images/green-16x16.png?f38 51w' sizes='100vw, 1px'> +<img srcset='/images/green-1x1.png?f39 50w, /images/green-16x16.png?f39 51w' sizes='100vw, (min-width:0) 1px'> +<img srcset='/images/green-1x1.png?f40 50w, /images/green-16x16.png?f40 51w' sizes='foo bar'> +<img srcset='/images/green-1x1.png?f41 50w, /images/green-16x16.png?f41 51w' sizes='foo-bar'> +<img srcset='/images/green-1x1.png?f42 50w, /images/green-16x16.png?f42 51w' sizes='(min-width:0) 1px foo bar'> +<img srcset='/images/green-1x1.png?f43 50w, /images/green-16x16.png?f43 51w' sizes='(min-width:0) 0.1%'> +<img srcset='/images/green-1x1.png?f44 50w, /images/green-16x16.png?f44 51w' sizes='(min-width:0) 1'> +<img srcset='/images/green-1x1.png?f45 50w, /images/green-16x16.png?f45 51w' sizes='-1e0px'> +<img srcset='/images/green-1x1.png?f46 50w, /images/green-16x16.png?f46 51w' sizes='1e1.5px'> +<img srcset='/images/green-1x1.png?f47 50w, /images/green-16x16.png?f47 51w' style='--foo: 1px' sizes='var(--foo)'> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/common.js b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/common.js new file mode 100644 index 000000000..d4d2c7534 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/common.js @@ -0,0 +1,25 @@ +setup({explicit_done:true}); + +function check(img) { + var name = format_value(img.getAttribute('srcset')); + if (img.hasAttribute('sizes')) { + name += ' sizes=' + format_value(img.getAttribute('sizes')); + } + if (img.hasAttribute('data-desc')) { + name += ' (' + img.getAttribute('data-desc') + ')'; + } + test(function() { + var expect = img.dataset.expect; + if ('resolve' in img.dataset) { + var a = document.createElement('a'); + a.href = expect; + expect = a.href; + } + assert_equals(img.currentSrc, expect); + }, name); +} + +onload = function() { + [].forEach.call(document.images, check); + done(); +}; diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html new file mode 100644 index 000000000..ce1e4cebe --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html @@ -0,0 +1,245 @@ +<!doctype html> +<title>img parse a srcset attribute</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src=common.js></script> +<div id=log></div> +<!-- splitting loop --> +<img srcset='' data-expect=''> +<img srcset=',' data-expect=''> +<img srcset=',,,' data-expect=''> +<img srcset=' data:,a 1x ' data-expect='data:,a'> +<img srcset='		data:,a		1x		' data-expect='data:,a'> +<img srcset='

data:,a

1x

' data-expect='data:,a'> +<img srcset='data:,a1x' data-expect='data:,a1x' data-resolve> +<img srcset='data:,a1x' data-expect='data:,a'> +<img srcset='

data:,a

1x

' data-expect='data:,a'> +<img srcset='data:,a1x' data-expect='data:,a1x' data-resolve> +<img srcset='data:,a1x' data-expect='data:,a1x' data-resolve> +<img srcset='data:,a1x' data-expect='data:,a1x' data-resolve> +<img srcset='data:,a' data-expect='data:,a'> +<img srcset='data:,a ' data-expect='data:,a'> +<img srcset='data:,a ,' data-expect='data:,a'> +<img srcset='data:,a,' data-expect='data:,a'> +<img srcset='data:,a, ' data-expect='data:,a'> +<img srcset='data:,a,,,' data-expect='data:,a'> +<img srcset='data:,a,, , ' data-expect='data:,a'> +<img srcset=' data:,a' data-expect='data:,a'> +<img srcset=',,,data:,a' data-expect='data:,a'> +<img srcset=' , ,,data:,a' data-expect='data:,a'> +<img srcset=' data:,a' data-expect=' data:,a' data-resolve> +<img srcset='data:,a ' data-expect='data:,a ' data-resolve> +<!-- descriptor tokenizer --> +<img srcset='data:,a 1x' data-expect='data:,a'> +<img srcset='data:,a 1x ' data-expect='data:,a'> +<img srcset='data:,a 1x,' data-expect='data:,a'> +<img srcset='data:,a ( , data:,b 1x, ), data:,c' data-expect='data:,c'> +<img srcset='data:,a ((( , data:,b 1x, ), data:,c' data-expect='data:,c'> +<img srcset='data:,a [ , data:,b 1x, ], data:,c' data-expect='data:,b'> +<img srcset='data:,a { , data:,b 1x, }, data:,c' data-expect='data:,b'> +<img srcset='data:,a " , data:,b 1x, ", data:,c' data-expect='data:,b'> +<img srcset='data:,a \,data:;\,b, data:,c' data-expect='data:;\,b'> +<img srcset='data:,a, data:,b (' data-expect='data:,a'> +<img srcset='data:,a, data:,b ( ' data-expect='data:,a'> +<img srcset='data:,a, data:,b (,' data-expect='data:,a'> +<img srcset='data:,a, data:,b (x' data-expect='data:,a'> +<img srcset='data:,a, data:,b ()' data-expect='data:,a'> +<img srcset='data:,a (, data:,b' data-expect=''> +<img srcset='data:,a /*, data:,b, data:,c */' data-expect='data:,b'> +<img srcset='data:,a //, data:,b' data-expect='data:,b'> +<!-- descriptor parser --> +<img srcset='data:,a foo' data-expect=''> +<img srcset='data:,a foo foo' data-expect=''> +<img srcset='data:,a foo 1x' data-expect=''> +<img srcset='data:,a foo 1x foo' data-expect=''> +<img srcset='data:,a foo 1w' data-expect=''> +<img srcset='data:,a foo 1w foo' data-expect=''> +<img srcset='data:,a 1x 1x' data-expect=''> +<img srcset='data:,a 1w 1w' data-expect=''> +<img srcset='data:,a 1w 1x' data-expect=''> +<img srcset='data:,a 1x 1w' data-expect=''> +<img srcset='data:,a 1w 1h' data-expect='data:,a'><!-- should fail for x-only impl --> +<img srcset='data:,a 1h 1w' data-expect='data:,a'><!-- should fail for x-only impl --> +<img srcset='data:,a 1h 1h' data-expect=''> +<img srcset='data:,a 1h 1x' data-expect=''> +<img srcset='data:,a 1h 1w 1x' data-expect=''> +<img srcset='data:,a 1x 1w 1h' data-expect=''> +<img srcset='data:,a 1w' data-expect='data:,a'><!-- should fail for x-only impl --> +<img srcset='data:,a 1h' data-expect=''> +<img srcset='data:,a 1h foo' data-expect=''> +<img srcset='data:,a foo 1h' data-expect=''> +<img srcset='data:,a 0w' data-expect=''> +<img srcset='data:,a -1w' data-expect=''> +<img srcset='data:,a 1w -1w' data-expect=''> +<img srcset='data:,a 1.0w' data-expect=''> +<img srcset='data:,a 1w 1.0w' data-expect=''> +<img srcset='data:,a 1e0w' data-expect=''> +<img srcset='data:,a 1w 1e0w' data-expect=''> +<img srcset='data:,a 1www' data-expect=''> +<img srcset='data:,a 1w 1www' data-expect=''> +<img srcset='data:,a +1w' data-expect=''> +<img srcset='data:,a 1w +1w' data-expect=''> +<img srcset='data:,a 1W' data-expect=''> +<img srcset='data:,a 1w 1W' data-expect=''> +<img srcset='data:,a Infinityw' data-expect=''> +<img srcset='data:,a 1w Infinityw' data-expect=''> +<img srcset='data:,a NaNw' data-expect=''> +<img srcset='data:,a 1w NaNw' data-expect=''> +<img srcset='data:,a 0x1w' data-expect=''> +<img srcset='data:,a 0X1w' data-expect=''> +<img srcset='data:,a 1w' data-expect='' data-desc='trailing U+0001'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+00A0'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+1680'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2000'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2001'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2002'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2003'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2004'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2005'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2006'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2007'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2008'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+2009'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+200A'> +<img srcset='data:,a 1‌w' data-expect='' data-desc='trailing U+200C'> +<img srcset='data:,a 1‍w' data-expect='' data-desc='trailing U+200D'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+202F'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+205F'> +<img srcset='data:,a 1 w' data-expect='' data-desc='trailing U+3000'> +<img srcset='data:,a 1w' data-expect='' data-desc='trailing U+FEFF'> +<img srcset='data:,a 1w' data-expect='' data-desc='leading U+0001'> +<img srcset='data:,a 1w' data-expect='' data-desc='leading U+00A0'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+1680'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2000'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2001'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2002'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2003'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2004'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2005'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2006'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2007'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2008'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+2009'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+200A'> +<img srcset='data:,a ‌1w' data-expect='' data-desc='leading U+200C'> +<img srcset='data:,a ‍1w' data-expect='' data-desc='leading U+200D'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+202F'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+205F'> +<img srcset='data:,a  1w' data-expect='' data-desc='leading U+3000'> +<img srcset='data:,a 1w' data-expect='' data-desc='leading U+FEFF'> +<img srcset='data:,a 0x' data-expect='data:,a'> +<img srcset='data:,a -0x' data-expect='data:,a'> +<img srcset='data:,a 1x -0x' data-expect=''> +<img srcset='data:,a -1x' data-expect=''> +<img srcset='data:,a 1x -1x' data-expect=''> +<img srcset='data:,a 1e0x' data-expect='data:,a'> +<img srcset='data:,a 1E0x' data-expect='data:,a'> +<img srcset='data:,a 1e-1x' data-expect='data:,a'> +<img srcset='data:,a 1.5e1x' data-expect='data:,a'> +<img srcset='data:,a -x' data-expect=''> +<img srcset='data:,a .x' data-expect=''> +<img srcset='data:,a -.x' data-expect=''> +<img srcset='data:,a 1.x' data-expect=''> +<img srcset='data:,a .5x' data-expect='data:,a'> +<img srcset='data:,a .5e1x' data-expect='data:,a'> +<img srcset='data:,a 1x 1.5e1x' data-expect=''> +<img srcset='data:,a 1x 1e1.5x' data-expect=''> +<img srcset='data:,a 1.0x' data-expect='data:,a'> +<img srcset='data:,a 1x 1.0x' data-expect=''> +<img srcset='data:,a +1x' data-expect=''> +<img srcset='data:,a 1X' data-expect=''> +<img srcset='data:,a Infinityx' data-expect=''> +<img srcset='data:,a NaNx' data-expect=''> +<img srcset='data:,a 0x1x' data-expect=''> +<img srcset='data:,a 0X1x' data-expect=''> +<img srcset='data:,a 1x' data-expect='' data-desc='trailing U+0001'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+00A0'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+1680'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2000'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2001'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2002'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2003'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2004'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2005'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2006'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2007'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2008'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+2009'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+200A'> +<img srcset='data:,a 1‌x' data-expect='' data-desc='trailing U+200C'> +<img srcset='data:,a 1‍x' data-expect='' data-desc='trailing U+200D'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+202F'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+205F'> +<img srcset='data:,a 1 x' data-expect='' data-desc='trailing U+3000'> +<img srcset='data:,a 1x' data-expect='' data-desc='trailing U+FEFF'> +<img srcset='data:,a 1x' data-expect='' data-desc='leading U+0001'> +<img srcset='data:,a 1x' data-expect='' data-desc='leading U+00A0'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+1680'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2000'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2001'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2002'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2003'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2004'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2005'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2006'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2007'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2008'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+2009'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+200A'> +<img srcset='data:,a ‌1x' data-expect='' data-desc='leading U+200C'> +<img srcset='data:,a ‍1x' data-expect='' data-desc='leading U+200D'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+202F'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+205F'> +<img srcset='data:,a  1x' data-expect='' data-desc='leading U+3000'> +<img srcset='data:,a 1x' data-expect='' data-desc='leading U+FEFF'> +<img srcset='data:,a 1w 0h' data-expect=''> +<img srcset='data:,a 1w -1h' data-expect=''> +<img srcset='data:,a 1w 1.0h' data-expect=''> +<img srcset='data:,a 1w 1e0h' data-expect=''> +<img srcset='data:,a 1w 1hhh' data-expect=''> +<img srcset='data:,a 1w +1h' data-expect=''> +<img srcset='data:,a 1w 1H' data-expect=''> +<img srcset='data:,a 1w Infinityh' data-expect=''> +<img srcset='data:,a 1w NaNh' data-expect=''> +<img srcset='data:,a 0x1h' data-expect=''> +<img srcset='data:,a 0X1h' data-expect=''> +<img srcset='data:,a 1w 1h' data-expect='' data-desc='trailing U+0001'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+00A0'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+1680'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2000'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2001'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2002'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2003'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2004'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2005'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2006'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2007'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2008'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+2009'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+200A'> +<img srcset='data:,a 1w 1‌h' data-expect='' data-desc='trailing U+200C'> +<img srcset='data:,a 1w 1‍h' data-expect='' data-desc='trailing U+200D'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+202F'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+205F'> +<img srcset='data:,a 1w 1 h' data-expect='' data-desc='trailing U+3000'> +<img srcset='data:,a 1w 1h' data-expect='' data-desc='trailing U+FEFF'> +<img srcset='data:,a 1w 1h' data-expect='' data-desc='leading U+0001'> +<img srcset='data:,a 1w 1h' data-expect='' data-desc='leading U+00A0'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+1680'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2000'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2001'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2002'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2003'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2004'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2005'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2006'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2007'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2008'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+2009'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+200A'> +<img srcset='data:,a 1w ‌1h' data-expect='' data-desc='leading U+200C'> +<img srcset='data:,a 1w ‍1h' data-expect='' data-desc='leading U+200D'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+202F'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+205F'> +<img srcset='data:,a 1w  1h' data-expect='' data-desc='leading U+3000'> +<img srcset='data:,a 1w 1h' data-expect='' data-desc='leading U+FEFF'> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/select-an-image-source.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/select-an-image-source.html new file mode 100644 index 000000000..292395d3a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/srcset/select-an-image-source.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>img select an image source</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src=common.js></script> +<div id=log></div> +<!-- dup entries --> +<img srcset='data:,a 1x, data:,b 1x' data-expect='data:,a'> +<img srcset='data:,a , data:,b 1x' data-expect='data:,a'> +<img srcset='data:,a 1x, data:,b' data-expect='data:,a'> +<img srcset='data:,a 1w, data:,b 1w' data-expect='data:,a'> +<img srcset='data:,a 1w 1h, data:,b 1w' data-expect='data:,a'> +<img srcset='data:,a 1w, data:,b 1w 1h' data-expect='data:,a'> +<img srcset='data:,a 1w 1h, data:,b 1w 2h' data-expect='data:,a'> +<img srcset='data:,a 1w 2h, data:,b 1w 1h' data-expect='data:,a'> +<img srcset='data:,a , data:,b' data-expect='data:,a'> +<img srcset='data:,a 1w, data:,b 1x' sizes='1px' data-expect='data:,a'> +<img srcset='data:,a 1x, data:,b 1w' sizes='1px' data-expect='data:,a'> +<img srcset='data:,a 1w, data:,b 2x' sizes='0.5px' data-expect='data:,a'> +<img srcset='data:,a 2x, data:,b 1w' sizes='0.5px' data-expect='data:,a'> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-media.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-media.html new file mode 100644 index 000000000..dd679ef57 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-media.html @@ -0,0 +1,32 @@ +<!doctype html> +<meta charset=utf-8> +<title>img update media</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + var t = async_test('set media after src updates selected image'); + + var img; + + onload = t.step_func(function() { + img = document.querySelector('img'); + img.addEventListener('load', t.step_func_done(onImgLoad)); + + var source = document.querySelector('source[data-media]'); + source.setAttribute('media', source.getAttribute('data-media')); + }); + + function onImgLoad() { + img.removeEventListener('load', onImgLoad); + + assert_true(img.currentSrc.indexOf(img.getAttribute('data-expect')) > -1); + } + +</script> + +<div id="log"></div> +<picture> + <source srcset="/images/fail.gif" data-media="(max-width: 1px)" /> + <source srcset="/images/smiley.png" /> + <img data-expect="/images/smiley.png"> +</picture>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-src-complete.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-src-complete.html new file mode 100644 index 000000000..20cb95915 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-src-complete.html @@ -0,0 +1,23 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Changing the img src should retain the 'complete' property</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<p id="display"><img src="image.png"></p>
+<script>
+ function check() {
+ var img = document.querySelector("img");
+ assert_true(img.complete, "By onload, image should have loaded");
+ img.src = `image.png?${Math.random()}`;
+ assert_false(img.complete, "Now that we're loading we should no longer be complete");
+ img.onload = function () {
+ assert_true(img.complete, "The new thing should have loaded.");
+ done();
+ }
+ }
+
+ onload = function () {
+ check();
+ }; +
+</script>
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/fail-to-resolve.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/fail-to-resolve.html new file mode 100644 index 000000000..959ceaa97 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/fail-to-resolve.html @@ -0,0 +1,25 @@ +<!doctype html> +<title>img update the image data: fail to resolve URL</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> + +<img src="//["> +<img srcset="//["> +<img srcset="//[" src="/images/red.png"> +<img srcset="//[, /images/red.png"> + +<script> +setup({explicit_done: true}); + +var expected = '//['; + +onload = function() { + [].forEach.call(document.images, function(img) { + test(function() { + assert_equals(img.currentSrc, expected); + }, img.outerHTML); + }); + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-source-set.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-source-set.html new file mode 100644 index 000000000..063667baa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-source-set.html @@ -0,0 +1,140 @@ +<!doctype html> +<title>img update the source set</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +setup({explicit_done:true}); + +function check(p) { + var img = p.querySelector('[data-expect]'); + test(function() { + var expect = img.dataset.expect; + if ('resolve' in img.dataset) { + var a = document.createElement('a'); + a.href = expect; + expect = a.href; + } + assert_equals(img.currentSrc, expect); + }, p.innerHTML); +} + +onload = function() { + [].forEach.call(document.querySelectorAll('div:not([id])'), check); + done(); +}; + +</script> +<div id=log></div> +<div><img data-expect=''></div> +<div><img src data-expect=''></div> +<div><img src='data:,a' data-expect='data:,a'></div> +<div><img srcset src='data:,a' data-expect='data:,a'></div> +<div><img srcset='data:,b' src='data:,a' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b' data-expect='data:,b'><!-- srcset after src --></div> +<div><img src='data:,a' srcset='data:,b 1x' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 1.0x' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 1e0x' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 10000w' sizes='1px' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 10000w, data:,c 10000x' sizes='1px' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 10000x, data:,c 10000w' sizes='1px' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 1w' sizes='10000px' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 1w, data:,c 0.0001x' sizes='10000px' data-expect='data:,b'></div> +<div><img src='data:,a' srcset='data:,b 0.0001x, data:,c 1w' sizes='10000px' data-expect='data:,b'></div> +<div><img srcset='data:,a' data-expect='data:,a'></div> + +<!-- child is not a <source> --> + +<div><picture>foo<img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><!--foo--><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><br><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><p></p><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><video><source srcset='data:,b'></video><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><span><source srcset='data:,b'></span><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><svg><source srcset='data:,b'/></svg><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><svg/><source srcset='data:,b'/><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><svg><font/><source srcset='data:,b'/></svg><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><svg><!--<font face> tag breaks out of svg--><font face></font><source srcset='data:,b'/></svg><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><img src='data:,a'><img src='data:,b' data-expect='data:,b'></picture></div> + +<!-- <source> has no srcset --> + +<div><picture><source><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source src='data:,b'><img src='data:,a' data-expect='data:,a'></picture></div> + +<!-- <source srcset> has zero candidates --> + +<div><picture><source srcset><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset=', ,'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b 1x 1x'><img src='data:,a' data-expect='data:,a'></picture></div> + +<!-- <source media> --> + +<div><picture><source srcset='data:,b' media><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' media='all'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' media='all and (min-width:0)'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' media='all and !'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' media='all and (!)'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' media='not all'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' media='not all and (min-width:0)'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' media='not all and (max-width:0)'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' media='not all and !'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' media='not all and (!)'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' media='all, !'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' media=','><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' media=', all'><img src='data:,a' data-expect='data:,b'></picture></div> + +<!-- <source type> assume support for gif, png, jpg, svg, ico --> + +<div><picture><source srcset='data:,b' type><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type=' '><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type=' image/gif'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif '><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif;'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif;encodings'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif;encodings='><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif;encodings=foobar'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/png'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/jpeg'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/svg+xml'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='image/x-icon'><img src='data:,a' data-expect='data:,b'></picture></div> +<div><picture><source srcset='data:,b' type='text/xml'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='text/html'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='text/plain'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='text/css'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='video/mp4'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='video/ogg'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='video/webm'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='unknown/unknown'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='application/octet-stream'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='application/x-shockwave-flash'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='image\gif'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='gif'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='.gif'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='*'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='*/*'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='image/*'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type=','><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif, image/png'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='image/gif image/png'><img src='data:,a' data-expect='data:,a'></picture></div> +<div><picture><source srcset='data:,b' type='image/foobarbaz'><img src='data:,a' data-expect='data:,a'></picture></div> + +<!-- trailing garbage --> + +<div><picture><img src='data:,a' data-expect='data:,a'>foo</picture></div> +<div><picture><img src='data:,a' data-expect='data:,a'><br></picture></div> +<div><picture><img src='data:,a' data-expect='data:,a'><!--foo--></picture></div> +<div><picture><img src='data:,a' data-expect='data:,a'><img src='data:,b'></picture></div> +<div><picture><img data-expect=''><img src='data:,b'></picture></div> +<div><picture><img src='data:,a' data-expect='data:,a'><source srcset='data:,b'></picture></div> +<div><picture><img data-expect=''><source srcset='data:,b'></picture></div> + +<!-- parent not picture --> + +<div><picture><span><source srcset='data:,b'><img data-expect=''></span></picture></div> +<div><picture><span><source srcset='data:,b'><img src='data:,a' data-expect='data:,a'></span></picture></div> +<div><picture><source srcset='data:,b'><span><img src='data:,a' data-expect='data:,a'></span></picture></div> + +<!-- no src --> + +<div><picture><source srcset='data:,b'><img data-expect='data:,b'></picture></div> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-map-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-map-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-map-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-attributes.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-attributes.html new file mode 100644 index 000000000..30fdcf520 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-attributes.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: object - attributes</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body onload="on_load()"> +<div id="log"></div> +<form> + <object id="obj1" data="blue.html" name="o" height="50" width="100"></object> + <object id="obj2" name="p" type="image/png"></object> +</form> +<script> + var obj1; + var obj2; + var t1 = async_test("object.contentWindow"); + var t3 = async_test("object.width"); + var t4 = async_test("object.height"); + + setup(function() { + obj1 = document.getElementById("obj1"); + obj2 = document.getElementById("obj2"); + }); + + function on_load () { + t1.step(function() { + assert_equals(obj1.contentWindow.name, "o", "The contentWindow's name of the object element should be 'o'."); + assert_equals(obj2.contentWindow, null, "The contentWindow of the object element should be null when it type attribute starts with 'image/'."); + obj1.setAttribute("name", "o1"); + assert_equals(obj1.name, "o1", "The name of the object element should be 'o1'."); + assert_equals(obj1.contentWindow.name, "o1", "The contentWindow's name of the object element should be 'o1'."); + obj1.removeAttribute("name"); + assert_equals(obj1.name, "", "The name of the object element should be empty string."); + assert_equals(obj1.contentWindow.name, "", "The contentWindow's name of the object element should be empty string."); + }); + t1.done() + + t3.step(function() { + assert_equals(getComputedStyle(obj1, null)["width"], "100px", "The width should be 100px."); + }); + t3.done(); + + t4.step(function() { + assert_equals(getComputedStyle(obj1, null)["height"], "50px", "The height should be 50px."); + }); + t4.done(); + } +</script> + +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-events.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-events.html new file mode 100644 index 000000000..9cd567173 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-events.html @@ -0,0 +1,80 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: object-events</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +async_test(function(t) { + var obj = document.createElement("object"); + obj.onerror = t.step_func_done(function(e){ + assert_equals(Object.getPrototypeOf(e).constructor, Event, "The error event should use the Event interface."); + assert_true(e.isTrusted, "The error event should be a trusted event."); + assert_false(e.cancelable, "The error event should not be a cancelable event."); + assert_false(e.bubbles, "The error event should not be a bubble event."); + assert_equals(e.target, obj, "The error event target should be the corresponding object element."); + }); + + obj.onload = t.step_func_done(function(e){ + assert_unreached("The load event should not be fired."); + }); + + obj.data = "file:\\http://nonexistent.html"; + document.body.appendChild(obj); +}, "error event"); + +async_test(function(t) { + var obj = document.createElement("object"); + obj.onerror = t.step_func_done(function(e){ + assert_equals(e.target, obj, + "The error event should be fired on our element"); + }); + obj.onload = t.step_func_done(function(e){ + assert_unreached("The load event should not be fired."); + }); + + obj.data = "http://test:test"; + document.body.appendChild(obj); +}, "error event"); + + +async_test(function(t) { + var obj = document.createElement("object"); + obj.onload = t.step_func_done(function(e){ + assert_equals(Object.getPrototypeOf(e).constructor, Event, "The load event should use the Event interface."); + assert_true(e.isTrusted, "The load event should be a trusted event."); + assert_false(e.cancelable, "The load event should not be a cancelable event."); + assert_false(e.bubbles, "The load event should not be a bubble event."); + assert_equals(e.target, obj, "The load event target should be the corresponding object element."); + }); + + obj.onerror = t.step_func_done(function(e){ + assert_unreached("The error event should not be fired."); + }); + + obj.data = "/images/blue.png"; + document.body.appendChild(obj); +}, "load event"); + +async_test(function(t) { + var obj = document.createElement("object"); + obj.onload = t.step_func_done(function(e){ + assert_true(obj.contentWindow instanceof Window, "The object element should represent a nested browsing context.") + assert_equals(Object.getPrototypeOf(e).constructor, Event, "The load event should use the Event interface."); + assert_true(e.isTrusted, "The load event should be a trusted event."); + assert_false(e.cancelable, "The load event should not be a cancelable event."); + assert_false(e.bubbles, "The load event should not be a bubble event."); + assert_equals(e.target, obj, "The load event target should be the corresponding object element."); + }); + + obj.onerror = t.step_func_done(function(e){ + assert_unreached("The error event should not be fired."); + }); + + obj.data = "about:blank"; + document.body.appendChild(obj); +}, "load event of about:blank"); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-fallback.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-fallback.html new file mode 100644 index 000000000..d5469a3ed --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-fallback.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: display fallback content</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + +var t1 = async_test("the typemustmatch attribute is specified"); +var t2 = async_test("the typemustmatch attribute is not specified"); + +</script> +<body onload="t1.done(); t2.done()"> +<object id="obj"></object> +<div id="log"></div> +<script> + +t1.step(function() { + var obj1 = document.createElement("object"); + obj1.setAttribute("data", "/images/blue.png"); + obj1.setAttribute("type", "text/plain"); + obj1.setAttribute("typemustmatch", ""); + obj1.onload = t1.step_func(function () { + assert_true("typeMustMatch" in obj1, "typeMustMatch is not supported."); + assert_unreached("The image of the first object should not be loaded."); + }); + document.getElementById("obj").appendChild(obj1); +}); + +t2.step(function () { + var obj2 = document.createElement("object"); + obj2.setAttribute("data", "test2.html"); + obj2.setAttribute("type", "text/plain"); + obj2.onload = t2.step_func( function () { + assert_not_equals(obj2.contentDocument, null, "The test2.html should be loaded."); + }); + document.getElementById("obj").appendChild(obj2); +}); + +</script> +</body> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-handler.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-handler.html new file mode 100644 index 000000000..a24554e0c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-handler.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: object - handler</title> +<link rel="author" title="Intel" href="http://www.intel.com" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<object id="test" name="obj" data="test0.html" type="text/html"></object> +<script> + +var t1 = async_test("The nested browsing context must be navigated to the resource specified by the data attribute."); +var t2 = async_test("The object.data must not be updated if the browsing context gets further navigated."); + +function callback(data) { + if (data == "test0") { + t1.step(function() { + var testEle = document.getElementById("test"); + assert_true(testEle.contentDocument.location.href.indexOf("test0.html") != -1, "The nested browsing context should be navigated to test0.html."); + window["obj"].history.replaceState({state:"ok"}, "mytitle ", "object-fallback.html"); + assert_not_equals(testEle.contentDocument.location.href.indexOf("object-fallback.html"), -1, "The nested browsing context should be replacement enabled."); + }); + t1.done(); + } else if (data == "test1") { + t2.step(function() { + var testEle = document.getElementById("test"); + assert_true(testEle.contentDocument.location.href.indexOf("test1.html") != -1, "The browsing context should be navigated to test1.html."); + assert_true(testEle.data.indexOf("test0.html") != -1, "The value of attribute data should not be updated."); + }); + t2.done(); + } +} + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test0.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test0.html new file mode 100644 index 000000000..17df71daa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test0.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<script> + +parent.callback("test0"); +document.location.href = "test1.html"; + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test1.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test1.html new file mode 100644 index 000000000..cf2423275 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test1.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<script> + +parent.callback("test1"); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test2.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test2.html new file mode 100644 index 000000000..e5061eaea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/test2.html @@ -0,0 +1,4 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: object - fallback</title> +<link rel="author" title="Intel" href="http://www.intel.com"> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-param-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-param-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-param-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-source-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-source-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-source-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-track-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-track-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-track-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/.gitkeep b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video-tabindex.html b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video-tabindex.html new file mode 100644 index 000000000..304487478 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video-tabindex.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<title>tabindex on video elements</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#video"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<div id="test"> +<video></video> +</div> +<script> +var t = async_test("Attributes shouldn't magically appear"); +on_event(window, "load", t.step_func(function() { + var el = document.getElementById("test").getElementsByTagName("video")[0]; + assert_equals(el.hasAttribute("tabindex"), false); + t.done() +})) +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content-ref.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content-ref.htm new file mode 100644 index 000000000..c02abb123 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content-ref.htm @@ -0,0 +1,12 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>HTML5 Media Elements: Content inside the 'video' element is not shown to the user.</title> + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + </head> + <body> + <div id='testcontent'> + </div> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content_image.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content_image.htm new file mode 100644 index 000000000..0808d894a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content_image.htm @@ -0,0 +1,16 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>HTML5 Media Elements: Content inside the 'video' element is not shown to the user.</title> + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#video" /> + <link rel="match" href="video_content-ref.htm" /> + <meta name="assert" content="Content inside the 'video' element is not shown to the user (image)." /> + </head> + <body> + <div id='testcontent'> + <video><img src="../../../../images/fail.gif" /></video> + </div> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content_text.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content_text.htm new file mode 100644 index 000000000..639fb73f8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_content_text.htm @@ -0,0 +1,16 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>HTML5 Media Elements: Content inside the 'video' element is not shown to the user.</title> + <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#video" /> + <link rel="match" href="video_content-ref.htm" /> + <meta name="assert" content="Content inside the 'video' element is not shown to the user." /> + </head> + <body> + <div id='testcontent'> + <video><p style="color: red;">FAIL</p></video> + </div> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster-ref.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster-ref.htm new file mode 100644 index 000000000..78c03626e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster-ref.htm @@ -0,0 +1,5 @@ +<!DOCTYPE HTML> +<meta charset=UTF-8> +<title>Reference for poster tests</title> +<link rel="author" title="Microsoft" href="http://www.microsoft.com/"> +<img src="/media/poster.png"> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster_absolute.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster_absolute.htm new file mode 100644 index 000000000..bec2b0fba --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster_absolute.htm @@ -0,0 +1,12 @@ +<!DOCTYPE HTML> +<meta charset=UTF-8> +<title>The 'HTMLVideoElement' interface supports setting 'poster' to an absolute URL</title> +<link rel="author" title="Microsoft" href="http://www.microsoft.com/"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-video-poster"> +<link rel="match" href="video_dynamic_poster-ref.htm"> +<meta name="assert" content="The 'HTMLVideoElement' interface supports setting 'poster' to an absolute URL"> +<video id="video0">Your browser does not support video.</video> +<script> +var testElem = document.getElementById("video0"); +testElem.poster = "/media/poster.png"; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster_relative.htm b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster_relative.htm new file mode 100644 index 000000000..4faca61c4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_dynamic_poster_relative.htm @@ -0,0 +1,12 @@ +<!DOCTYPE HTML> +<meta charset=UTF-8> +<title>The 'HTMLVideoElement' interface supports setting 'poster' to a relative URL</title> +<link rel="author" title="Microsoft" href="http://www.microsoft.com/"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-video-poster"> +<link rel="match" href="video_dynamic_poster-ref.htm"> +<meta name="assert" content="The 'HTMLVideoElement' interface supports setting 'poster' to a relative URL"> +<video id="video0">Your browser does not support video.</video> +<script> +var testElem = document.getElementById("video0"); +testElem.poster = "../../../../media/poster.png"; +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_initially_paused-ref.html b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_initially_paused-ref.html new file mode 100644 index 000000000..8556aabf2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_initially_paused-ref.html @@ -0,0 +1,8 @@ +<!DOCTYPE HTML> +<meta charset=UTF-8> +<title>Video elements should initially be paused</title> +<link rel="author" title="Microsoft" href="http://www.microsoft.com/"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-paused"> +<script src="/common/media.js"></script> +<p>The following video element should be paused. (All clocks at zero).</p> +<img src='/images/movie_300_frame_0.png'> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_initially_paused.html b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_initially_paused.html new file mode 100644 index 000000000..b2725b04a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-video-element/video_initially_paused.html @@ -0,0 +1,21 @@ +<!DOCTYPE HTML> +<meta charset=UTF-8> +<title>Video elements should initially be paused</title> +<link rel="match" href="video_initially_paused-ref.html"> +<link rel="author" title="Microsoft" href="http://www.microsoft.com/"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-paused"> +<script src="/common/media.js"></script> +<style> +div#video { + padding: 6px 3px; +} +</style> +<p>The following video element should be paused. (All clocks at zero).</p> +<div id=video> +<script> +document.write( + "<video src='"+ getVideoURI('/media/movie_300') + "' >" + + "Your browser does not support the video element." + + "<\/video>"); +</script> +</div> |