Skip to content

Commit

Permalink
Adapt html-media-capture tests to latest spec (web-platform-tests#5312)
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry authored Apr 7, 2017
1 parent 4204845 commit 0da700f
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 41 deletions.
4 changes: 2 additions & 2 deletions html-media-capture/capture_audio-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture audio to produce one audio file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='http://dev.w3.org/2009/dap/camera/#attributes'>
<link rel='help' href='http://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
Expand Down
4 changes: 2 additions & 2 deletions html-media-capture/capture_audio_cancel-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<meta charset='utf-8'>
<title>HTML Media Capture Test: user denial of captured audio leading to no capture</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='http://dev.w3.org/2009/dap/camera/#attributes'>
<link rel='help' href='http://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>

<p>Clear all microphone permissions before running this test. If prompted for permission, please allow.</p>
Expand Down
4 changes: 2 additions & 2 deletions html-media-capture/capture_fallback_file_upload-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture_fallback_file_upload</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='http://www.w3.org/TR/html-media-capture/#the-capture-attribute'>
<link rel='help' href='http://www.w3.org/TR/html5/forms.html#file-upload-state-(type=file)'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#file-upload-state-(type=file)'>
<meta name='flags' content='interact'>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
Expand Down
4 changes: 2 additions & 2 deletions html-media-capture/capture_image_cancel-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<meta charset='utf-8'>
<title>HTML Media Capture Test: user denial of captured image leading to no capture</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='http://dev.w3.org/2009/dap/camera/#attributes'>
<link rel='help' href='http://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>

<p>Clear all camera permissions before running this test. If prompted for permission, please allow.</p>
Expand Down
39 changes: 39 additions & 0 deletions html-media-capture/capture_image_environment-manual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture image with 'environment' facing mode to produce one image file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>

<p>Clear all camera permissions before running this test. If prompted for permission, please allow.</p>

<p>After hitting the button below, the camera must be launched with viewing the environment mode.</p>

<p>Capture an image and then confirm the capturing.</p>

<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>

<input type='file' accept='image/*' capture='environment'>

<div id='log'></div>

<script>
var input;

setup(function() {
input = document.querySelector('input[type=file]');
}, {explicit_done: true});

async_test(function(t) {
input.onchange = t.step_func_done(function() {
assert_equals(input.files.length, 1, 'Should capture one file');
assert_regexp_match(input.files[0].type, /^image\//, 'The captured file should be type of image');
});
done();
});
</script>

39 changes: 39 additions & 0 deletions html-media-capture/capture_image_invalid-manual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture image with implementation-specific default facing mode(invalid value default) to produce one image file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>

<p>Clear all camera permissions before running this test. If prompted for permission, please allow.</p>

<p>After hitting the button below, the camera must be launched with the default facing mode.</p>

<p>Capture an image and then confirm the capturing.</p>

<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>

<input type='file' accept='image/*' capture='invalid'>

<div id='log'></div>

<script>
var input;

setup(function() {
input = document.querySelector('input[type=file]');
}, {explicit_done: true});

async_test(function(t) {
input.onchange = t.step_func_done(function() {
assert_equals(input.files.length, 1, 'Should capture one file');
assert_regexp_match(input.files[0].type, /^image\//, 'The captured file should be type of image');
});
done();
});
</script>

Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture image to produce one image file</title>
<title>HTML Media Capture Test: capture image with implementation-specific default facing mode(missing value default) to produce one image file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='http://dev.w3.org/2009/dap/camera/#attributes'>
<link rel='help' href='http://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>

<p>Clear all camera permissions before running this test. If prompted for permission, please allow.</p>

<p>After hitting the button below, capture an image and then confirm the capturing.</p>
<p>After hitting the button below, the camera must be launched with the default facing mode.</p>

<p>Capture an image and then confirm the capturing.</p>

<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>

Expand Down
39 changes: 39 additions & 0 deletions html-media-capture/capture_image_user-manual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture image with 'user' facing mode to produce one image file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>

<p>Clear all camera permissions before running this test. If prompted for permission, please allow.</p>

<p>After hitting the button below, the camera must be launched with self-view mode.</p>

<p>Capture an image and then confirm the capturing.</p>

<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>

<input type='file' accept='image/*' capture='user'>

<div id='log'></div>

<script>
var input;

setup(function() {
input = document.querySelector('input[type=file]');
}, {explicit_done: true});

async_test(function(t) {
input.onchange = t.step_func_done(function() {
assert_equals(input.files.length, 1, 'Should capture one file');
assert_regexp_match(input.files[0].type, /^image\//, 'The captured file should be type of image');
});
done();
});
</script>

45 changes: 26 additions & 19 deletions html-media-capture/capture_reflect.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture_reflect</title>
<link rel='author' title='Intel' href='http://www.intel.com/'>
<link rel='help' href='http://www.w3.org/TR/html-media-capture/#the-capture-attribute'>
<link rel='help' href='http://www.w3.org/html/wg/drafts/html/CR/infrastructure.html#reflect'>
<link rel='help' href='http://www.w3.org/html/wg/drafts/html/CR/infrastructure.html#boolean-attributes'>
<link rel='help' href='https://w3c.github.io/html-media-capture/#the-capture-attribute'>
<meta name='flags' content='dom'>
<meta name='assert' content='Test checks that the capture IDL attribute must reflect the content attribute of the same name.'>
<script src='/resources/testharness.js'></script>
Expand All @@ -15,43 +13,52 @@
<body>
<pre style='display:none'>
partial interface HTMLInputElement {
attribute boolean capture;
attribute CaptureFacingMode capture;
};
enum CaptureFacingMode {
"user",
"environment"
};
</pre>

<div style='display:none'>
<input id='absent' type='file' accept='image/*'>
<input id='present' type='file' accept='image/*' capture>
<input id='present-empty-string' type='file' accept='image/*' capture=''>
<input id='present-canonical-name' type='file' accept='image/*' capture=capture>
<input id='present-missing' type='file' accept='image/*' capture>
<input id='present-user' type='file' accept='image/*' capture='user'>
<input id='present-invalid' type='file' accept='image/*' capture='invalid'>
<input id='present-environment' type='file' accept='image/*' capture='environment'>
</div>

<div id='log'></div>

<script>
test(function() {
var inputs = document.querySelectorAll('input');
for (var i=0, obj; i<inputs.length, obj=inputs[i]; i++) {
assert_own_property(obj, 'capture');
assert_equals(typeof obj.capture, 'boolean');
let inputs = document.querySelectorAll('input');
for (let i=0, obj; i<inputs.length, obj=inputs[i]; i++) {
assert_true('capture' in obj);
assert_equals(typeof obj.capture, 'string');
}
}, 'Element input should have own property capture');

test(function() {
assert_false(document.querySelector('#absent').capture);
}, 'input.capture is false when the capture attribute is absent');
assert_equals(document.querySelector('#absent').capture, "");
}, 'input.capture is "" when the capture attribute is absent');

test(function() {
assert_equals(document.querySelector('#present-missing').capture, "");
}, 'input.capture is "" when the capture attribute is missing value default');

test(function() {
assert_true(document.querySelector('#present').capture);
}, 'input.capture is true when the capture attribute is present');
assert_equals(document.querySelector('#present-user').capture, "user");
}, 'input.capture is "user" when the capture attribute is user');

test(function() {
assert_true(document.querySelector('#present-empty-string').capture);
}, 'input.capture is true when the capture attribute is present as empty string');
assert_equals(document.querySelector('#present-invalid').capture, "invalid");
}, 'input.capture is "invalid" when the capture attribute is invalid value default');

test(function() {
assert_true(document.querySelector('#present-canonical-name').capture);
}, 'input.capture is true when the capture attribute is present as canonical name');
assert_equals(document.querySelector('#present-environment').capture, "environment");
}, 'input.capture is "environment" when the capture attribute is environment');
</script>
</body>
</html>
4 changes: 2 additions & 2 deletions html-media-capture/capture_video_cancel-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<meta charset='utf-8'>
<title>HTML Media Capture Test: user denial of captured video leading to no capture</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='http://dev.w3.org/2009/dap/camera/#attributes'>
<link rel='help' href='http://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>

<p>Clear all camera/microphone permissions before running this test. If prompted for permission, please allow.</p>
Expand Down
39 changes: 39 additions & 0 deletions html-media-capture/capture_video_environment-manual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture video with 'environment' facing mode to produce one video file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>

<p>Clear all camera/microphone permissions before running this test. If prompted for permission, please allow.</p>

<p>After hitting the button below, the camera must be launched with viewing the environment mode.</p>

<p>Capture a video and then confirm the capturing.</p>

<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>

<input type='file' accept='video/*' capture='environment'>

<div id='log'></div>

<script>
var input;

setup(function() {
input = document.querySelector('input[type=file]');
}, {explicit_done: true});

async_test(function(t) {
input.onchange = t.step_func_done(function() {
assert_equals(input.files.length, 1, 'Should capture one file');
assert_regexp_match(input.files[0].type, /^video\//, 'The captured file should be type of video');
});
done();
});
</script>

39 changes: 39 additions & 0 deletions html-media-capture/capture_video_invalid-manual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture video with implementation-specific default facing mode(invalid value default) to produce one video file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>

<p>Clear all camera/microphone permissions before running this test. If prompted for permission, please allow.</p>

<p>After hitting the button below, the camera must be launched with the default facing mode.</p>

<p>Capture an video and then confirm the capturing.</p>

<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>

<input type='file' accept='video/*' capture='invalid'>

<div id='log'></div>

<script>
var input;

setup(function() {
input = document.querySelector('input[type=file]');
}, {explicit_done: true});

async_test(function(t) {
input.onchange = t.step_func_done(function() {
assert_equals(input.files.length, 1, 'Should capture one file');
assert_regexp_match(input.files[0].type, /^video\//, 'The captured file should be type of video');
});
done();
});
</script>

Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<title>HTML Media Capture Test: capture video to produce one video file</title>
<title>HTML Media Capture Test: capture video with implementation-specific default facing mode(missing value default) to produce one video file</title>
<link rel='author' title='Intel' href='http://www.intel.com'>
<link rel='help' href='http://dev.w3.org/2009/dap/camera/#attributes'>
<link rel='help' href='http://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<link rel='help' href='https://w3c.github.io/html-media-capture'>
<link rel='help' href='https://www.w3.org/TR/html5/forms.html#attr-input-accept'>
<meta name='flags' content='interact'>
<meta name="timeout" content="long">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>

<p>Clear all camera/microphone permissions before running this test. If prompted for permission, please allow.</p>

<p>After hitting the button below, capture an video and then confirm the capturing.</p>
<p>After hitting the button below, the camera must be launched with the default facing mode.</p>

<p>Capture an video and then confirm the capturing.</p>

<p>Note: All the actions need to be done in 60 seconds, otherwise it will get TIMEOUT.</p>

Expand Down
Loading

0 comments on commit 0da700f

Please sign in to comment.