| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import contextlib | 6 import contextlib |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 device: (device_utils.DeviceUtils) Android device to connect to. | 396 device: (device_utils.DeviceUtils) Android device to connect to. |
| 397 connection: devtools connection. | 397 connection: devtools connection. |
| 398 local_output_path: Output path were to save the video locally. | 398 local_output_path: Output path were to save the video locally. |
| 399 | 399 |
| 400 Yields: | 400 Yields: |
| 401 None | 401 None |
| 402 """ | 402 """ |
| 403 # Paint the current HTML document with the ORANGE that video is detecting with | 403 # Paint the current HTML document with the ORANGE that video is detecting with |
| 404 # the view-port position and size. | 404 # the view-port position and size. |
| 405 color = video.HIGHLIGHT_ORANGE_FRAME | 405 color = video.HIGHLIGHT_ORANGE_FRAME |
| 406 connection.ExecuteJavaScript(""" | 406 connection.ExecuteJavaScript2(""" |
| 407 (function() { | 407 (function() { |
| 408 var screen = document.createElement('div'); | 408 var screen = document.createElement('div'); |
| 409 screen.style.background = 'rgb(%d, %d, %d)'; | 409 screen.style.background = 'rgb({{ red }}, {{ green }}, {{ blue }})'; |
| 410 screen.style.position = 'fixed'; | 410 screen.style.position = 'fixed'; |
| 411 screen.style.top = '0'; | 411 screen.style.top = '0'; |
| 412 screen.style.left = '0'; | 412 screen.style.left = '0'; |
| 413 screen.style.width = '100%%'; | 413 screen.style.width = '100%'; |
| 414 screen.style.height = '100%%'; | 414 screen.style.height = '100%'; |
| 415 screen.style.zIndex = '2147483638'; | 415 screen.style.zIndex = '2147483638'; |
| 416 document.body.appendChild(screen); | 416 document.body.appendChild(screen); |
| 417 requestAnimationFrame(function() { | |
| 418 requestAnimationFrame(function() { | 417 requestAnimationFrame(function() { |
| 419 window.__speedindex_screen = screen; | 418 requestAnimationFrame(function() { |
| 419 window.__speedindex_screen = screen; |
| 420 }); |
| 420 }); | 421 }); |
| 421 }); | 422 })(); |
| 422 })(); | 423 """, |
| 423 """ % (color.r, color.g, color.b)) | 424 red=color.r, green=color.g, blue=color.b) |
| 424 connection.PollForJavaScriptExpression('!!window.__speedindex_screen', 1) | 425 connection.PollForJavaScriptExpression('!!window.__speedindex_screen', 1) |
| 425 | 426 |
| 426 with _RemoteVideoRecorder(device, local_output_path, | 427 with _RemoteVideoRecorder(device, local_output_path, |
| 427 megabits_per_second=_SPEED_INDEX_VIDEO_BITRATE): | 428 megabits_per_second=_SPEED_INDEX_VIDEO_BITRATE): |
| 428 # Paint the current HTML document with white so that it is not troubling the | 429 # Paint the current HTML document with white so that it is not troubling the |
| 429 # speed index measurement. | 430 # speed index measurement. |
| 430 connection.ExecuteJavaScript(""" | 431 connection.ExecuteJavaScript2(""" |
| 431 (function() { | 432 (function() { |
| 432 requestAnimationFrame(function() { | 433 requestAnimationFrame(function() { |
| 433 var screen = window.__speedindex_screen; | 434 var screen = window.__speedindex_screen; |
| 434 screen.style.background = 'rgb(255, 255, 255)'; | 435 screen.style.background = 'rgb(255, 255, 255)'; |
| 435 }); | 436 }); |
| 436 })(); | 437 })(); |
| 437 """) | 438 """) |
| 438 yield | 439 yield |
| OLD | NEW |