1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32

content / test / data / gpu / pixel_video_media_stream_test.js [blame]

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var video;

// Some videos are less than 60 fps, so actual video frame presentations
// could be much less than 30.
var g_swaps_before_success = 30

async function main() {
  video = document.getElementById("video");
  video.loop = true;
  video.requestVideoFrameCallback(waitForVideoToPlay);
  video.srcObject = await navigator.mediaDevices.getUserMedia({video: true});
  video.play();
}

function waitForVideoToPlay() {
  chrome.gpuBenchmarking.addSwapCompletionEventListener(
      waitForSwapsToComplete);
}

function waitForSwapsToComplete() {
  g_swaps_before_success--;
  if (g_swaps_before_success > 0) {
    chrome.gpuBenchmarking.addSwapCompletionEventListener(
        waitForSwapsToComplete);
  } else {
    domAutomationController.send("SUCCESS");
  }
}