| 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 from telemetry.page import page as page_module | 5 from telemetry.page import page as page_module |
| 6 from telemetry.page import shared_page_state | 6 from telemetry.page import shared_page_state |
| 7 from telemetry import story | 7 from telemetry import story |
| 8 | 8 |
| 9 | 9 |
| 10 URL_LIST = [ | 10 URL_LIST = [ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 # WindowProxy::initialize portion before the commit. To fix this, we'll | 32 # WindowProxy::initialize portion before the commit. To fix this, we'll |
| 33 # have to migrate to TBMv2. | 33 # have to migrate to TBMv2. |
| 34 self.script_to_evaluate_on_commit = ( | 34 self.script_to_evaluate_on_commit = ( |
| 35 'console.time("%s");' % INTERACTION_NAME) | 35 'console.time("%s");' % INTERACTION_NAME) |
| 36 | 36 |
| 37 def RunPageInteractions(self, action_runner): | 37 def RunPageInteractions(self, action_runner): |
| 38 action_runner.ExecuteJavaScript( | 38 action_runner.ExecuteJavaScript( |
| 39 """ | 39 """ |
| 40 this.becameIdle = false; | 40 this.becameIdle = false; |
| 41 this.idleCallback = function(deadline) { | 41 this.idleCallback = function(deadline) { |
| 42 let idletime = deadline.timeRemaining(); | 42 if (deadline.timeRemaining() > 20) |
| 43 console.time("time remaining: " + idletime); | |
| 44 if (idletime > 20) | |
| 45 this.becameIdle = true; | 43 this.becameIdle = true; |
| 46 else | 44 else |
| 47 requestIdleCallback(this.idleCallback); | 45 requestIdleCallback(this.idleCallback); |
| 48 console.timeEnd("time remaining: " + idletime); | |
| 49 }; | 46 }; |
| 50 requestIdleCallback(this.idleCallback); | 47 requestIdleCallback(this.idleCallback); |
| 51 """ | 48 """ |
| 52 ) | 49 ) |
| 53 action_runner.WaitForJavaScriptCondition('this.becameIdle === true') | 50 action_runner.WaitForJavaScriptCondition('this.becameIdle === true') |
| 54 action_runner.ExecuteJavaScript('console.timeEnd("%s");' % INTERACTION_NAME) | 51 action_runner.ExecuteJavaScript('console.timeEnd("%s");' % INTERACTION_NAME) |
| 55 | 52 |
| 56 | 53 |
| 57 class TodoMVCPageSet(story.StorySet): | 54 class TodoMVCPageSet(story.StorySet): |
| 58 | 55 |
| 59 """ TodoMVC examples """ | 56 """ TodoMVC examples """ |
| 60 | 57 |
| 61 def __init__(self): | 58 def __init__(self): |
| 62 super(TodoMVCPageSet, self).__init__( | 59 super(TodoMVCPageSet, self).__init__( |
| 63 archive_data_file='data/todomvc.json', | 60 archive_data_file='data/todomvc.json', |
| 64 cloud_storage_bucket=story.PUBLIC_BUCKET) | 61 cloud_storage_bucket=story.PUBLIC_BUCKET) |
| 65 | 62 |
| 66 for name, url in URL_LIST: | 63 for name, url in URL_LIST: |
| 67 self.AddStory(TodoMVCPage(url, self, name)) | 64 self.AddStory(TodoMVCPage(url, self, name)) |
| OLD | NEW |