Index: third_party/WebKit/LayoutTests/media/video-defaultmuted.html |
diff --git a/third_party/WebKit/LayoutTests/media/video-defaultmuted.html b/third_party/WebKit/LayoutTests/media/video-defaultmuted.html |
index f58e5ce8d50c295243ea2852b6b66a012aec4c6b..67623dde45c432db5951d459f14ca64b622895e0 100644 |
--- a/third_party/WebKit/LayoutTests/media/video-defaultmuted.html |
+++ b/third_party/WebKit/LayoutTests/media/video-defaultmuted.html |
@@ -1,92 +1,38 @@ |
-<!doctype html> |
-<html> |
- <head> |
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 |
- (Please avoid writing new tests using video-test.js) --> |
- <script src=video-test.js></script> |
- <script src=media-file.js></script> |
- <script> |
- var index = 0; |
- |
- function testMuted(expectedMuted, expectedDefaultMuted) |
- { |
- testExpected("video.muted", expectedMuted); |
- testExpected("video.defaultMuted", expectedDefaultMuted); |
- } |
- |
- function test(defaultMuted) |
- { |
- consoleWrite("<br><br><b>*** Test <em>" + (defaultMuted ? "with" : "without") + "</em> 'muted' content attribute</b><br>"); |
- |
- run("video = document.createElement('video')"); |
- run("video.setAttribute('controls', 'controls')"); |
- video.setAttribute('width', '300'); |
- if (defaultMuted) |
- run("video.setAttribute('muted', 'muted')"); |
- document.getElementById('parent').appendChild(video); |
- |
- consoleWrite("<br>*** Test before setting src, IDL attribute should default to false"); |
- testMuted(false, defaultMuted); |
- |
- var loadedmetadata = function(evt) |
- { |
- consoleWrite("<br>EVENT(" + evt.type + ")"); |
- |
- consoleWrite("<br>*** After setting url, content attribute should have set IDL attribute"); |
- testMuted(defaultMuted, defaultMuted); |
- |
- consoleWrite("<br>*** Change 'defaultMuted', IDL attribute should not change but content attribute should."); |
- var newDefaultMuted = !defaultMuted; |
- run("video.defaultMuted = " + newDefaultMuted); |
- testMuted(defaultMuted, newDefaultMuted); |
- testExpected("video.hasAttribute('muted')", newDefaultMuted); |
- |
- consoleWrite("<br>*** Change 'muted' IDL attribute, content attribute should not change"); |
- run("video.muted = false"); |
- testMuted(false, newDefaultMuted); |
- testExpected("video.hasAttribute('muted')", newDefaultMuted); |
- |
- var action = defaultMuted ? "Remove" : "Add"; |
- consoleWrite("<br>*** " + action + " 'muted' content attribute, it should have no effect on IDL attribute"); |
- if (defaultMuted) |
- run("video.removeAttribute('muted')"); |
- else |
- run("video.setAttribute('muted', 'muted')"); |
- testMuted(false, video.hasAttribute('muted')); |
- |
- runNextTest(); |
- } |
- video.addEventListener('loadedmetadata', loadedmetadata); |
- video.src = findMediaFile("audio", "content/test"); |
- } |
- |
- function runNextTest() |
- { |
- if (video) { |
- video.parentNode.removeChild(video); |
- video = null; |
- } |
- |
- switch (++index) |
- { |
- case 1: |
- test(true); |
- break; |
- case 2: |
- test(false); |
- break; |
- case 3: |
- consoleWrite(""); |
- endTest(); |
- break; |
- } |
- } |
- |
- </script> |
- </head> |
- |
- <body onload="runNextTest()"> |
- <div id="parent"></div> |
- <p>Test 'muted' content attribute<p> |
- </body> |
-</html> |
+<!DOCTYPE html> |
+<title>Test "defaultMuted" IDL, "muted" IDL and content attributes.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="media-file.js"></script> |
+<script> |
+test(function() { |
+ var video = document.createElement("video"); |
+ // Test that "defaultMuted" IDL attribute reflects "muted" content attribute and |
+ // that "muted" IDL attribute is not affected by content attribute. |
+ assert_false(video.muted); |
+ assert_false(video.defaultMuted); |
+ video.setAttribute("muted", "muted"); |
+ assert_false(video.muted); |
+ assert_true(video.defaultMuted); |
+ video.removeAttribute("muted", "muted"); |
+ assert_false(video.muted); |
+ assert_false(video.defaultMuted); |
+ |
+ // Test that "muted" IDL attribute is not affected by "defaultMuted" IDL attribute. |
+ video.defaultMuted = true; |
+ assert_false(video.muted); |
+}, "Test 'defaultMuted' and 'muted' IDL attributes"); |
+ |
+async_test(function(t) { |
+ var video = document.createElement("video"); |
+ // Set "muted" content attribute and it should set "muted" IDL attribute on video load. |
+ // This is wrong per spec. See https://crbug.com/350303 for details. |
+ video.setAttribute("muted", "muted"); |
+ |
+ video.onloadedmetadata = t.step_func_done(function() { |
+ // "muted" IDL attribute should have been set. |
+ assert_true(video.muted); |
+ }); |
+ |
+ video.src = findMediaFile("audio", "content/test"); |
+}, "Test 'muted' content and IDL attributes on video load"); |
+</script> |