| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Testing video rotation in media recorder</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <video id="recordedVideo" autoplay playsInline width="320" height="240"></video> |
| <script> |
| promise_test(async (test) => { |
| const stream = await navigator.mediaDevices.getUserMedia({video: true }); |
| let expectedWidth = 640; |
| let expectedHeight = 480; |
| |
| if (window.internals) { |
| window.internals.setCameraMediaStreamTrackOrientation(stream.getVideoTracks()[0], 90); |
| testRunner.setMockCameraOrientation(90); |
| |
| expectedWidth = 480; |
| expectedHeight = 640; |
| } |
| |
| const recorder = new MediaRecorder(stream); |
| const promise = new Promise((resolve, reject) => { |
| recorder.ondataavailable = (e) => resolve(e.data); |
| setTimeout(() => reject("datavailable event timed out"), 5000); |
| }); |
| recorder.start(); |
| setTimeout(() => recorder.stop(), 1000); |
| const blob = await promise; |
| |
| const url = URL.createObjectURL(blob); |
| recordedVideo.src = url; |
| await recordedVideo.play(); |
| |
| URL.revokeObjectURL(url); |
| |
| assert_equals(recordedVideo.videoWidth, expectedWidth, "recorded video width"); |
| assert_equals(recordedVideo.videoHeight, expectedHeight, "recorded video height"); |
| }, "Record a rotated video"); |
| </script> |
| </body> |
| </html> |