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
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69

content / test / data / gpu / core_animation_status_api.html [blame]

<!DOCTYPE HTML>
<html>
<head>
<title>GPU Benchmarking Core Animation Status API Test</title>
<script>

const parsedString = (function (names) {
  const pairs = {};
  for (let i = 0; i < names.length; ++i) {
    var keyValue = names[i].split('=', 2);
    if (keyValue.length == 1)
      pairs[keyValue[0]] = '';
    else
      pairs[keyValue[0]] = decodeURIComponent(keyValue[1].replace(/\+/g, ' '));
  }
  return pairs;
})(window.location.search.substr(1).split('&'));

// Command line '--enable-gpu-benchmarking' is required for this test.
function main() {
  var expectedError = parsedString['error'];
  if (expectedError == undefined)
    expectedError = 0;  // gfx::kCALayerSuccess = 0,

  const container = document.getElementById('container');
  const icon = document.createElement('icon');
  icon.style.backgroundColor = 'Red';
  icon.style.position = "absolute";
  icon.style.width = '100px';
  icon.style.height = '100px';
  icon.style.top = '0px';
  icon.style.left = '0px';
  container.appendChild(icon);

  // If core_animation_status_api.html is tested with a command line
  // '--disable-features=CoreAnimationRenderer' which causes overlay to fail.
  // The error code would be 32 (gfx::kCALayerFailedOverlayDisabled).
  // (See "ui/gfx/ca_layer_result.h" for error code.)
  function errorCodeHandler(errorCode) {
    if (errorCode == expectedError) {
      window.domAutomationController.send("SUCCESS");
    } else {
      console.log("Error code should be ", expectedError, ", got ", errorCode);
      window.domAutomationController.send("FAILED");
    }
  }

  function animation() {
     if (!chrome.gpuBenchmarking.addCoreAnimationStatusEventListener(errorCodeHandler)) {
       console.log("addCoreAnimationStatusEventListener failed!");
       window.domAutomationController.send("FAILED");
     }

     // if gpuBenchmarking is not supported, the test will not reach here and
     // the final output shows a red quad instead of a bluish quad.
     icon.style.left = '200px';
     icon.style.backgroundColor = "rgba(90, 129, 193, 255)";
  }

  window.requestAnimationFrame(animation);
}

</script>
</head>
<body onload="main()">
  <div id="container" style="position:absolute; top:0px; left:0px">
  </div>
</body>
</html>