| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from telemetry.page import page as page_module | |
| 6 from telemetry.page import shared_page_state | |
| 7 from telemetry import story | |
| 8 from telemetry.util import js_template | |
| 9 | |
| 10 | |
| 11 URL_LIST = [ | |
| 12 ('Polymer', 'http://todomvc.com/examples/polymer'), | |
| 13 ('AngularJS', 'http://todomvc.com/examples/angularjs'), | |
| 14 ('React', 'http://todomvc.com/examples/react'), | |
| 15 ('Backbone.js', 'http://todomvc.com/examples/backbone'), | |
| 16 ('Ember.js', 'http://todomvc.com/examples/emberjs'), | |
| 17 ('Closure', 'http://todomvc.com/examples/closure'), | |
| 18 ('GWT', 'http://todomvc.com/examples/gwt'), | |
| 19 ('Dart', 'http://todomvc.com/examples/vanilladart/build/web'), | |
| 20 ('Vanilla JS', 'http://todomvc.com/examples/vanillajs'), | |
| 21 ] | |
| 22 | |
| 23 INTERACTION_NAME = 'Interaction.AppLoad' | |
| 24 | |
| 25 | |
| 26 class TodoMVCPage(page_module.Page): | |
| 27 | |
| 28 def __init__(self, url, page_set, name): | |
| 29 super(TodoMVCPage, self).__init__( | |
| 30 url=url, page_set=page_set, name=name, | |
| 31 shared_page_state_class=shared_page_state.SharedDesktopPageState) | |
| 32 # TODO(jochen): This interaction does not include the | |
| 33 # WindowProxy::initialize portion before the commit. To fix this, we'll | |
| 34 # have to migrate to TBMv2. | |
| 35 self.script_to_evaluate_on_commit = js_template.Render( | |
| 36 'console.time({{ label }});', label=INTERACTION_NAME) | |
| 37 | |
| 38 def RunPageInteractions(self, action_runner): | |
| 39 action_runner.ExecuteJavaScript( | |
| 40 """ | |
| 41 this.becameIdle = false; | |
| 42 this.idleCallback = function(deadline) { | |
| 43 if (deadline.timeRemaining() > 20) | |
| 44 this.becameIdle = true; | |
| 45 else | |
| 46 requestIdleCallback(this.idleCallback); | |
| 47 }; | |
| 48 requestIdleCallback(this.idleCallback); | |
| 49 """ | |
| 50 ) | |
| 51 action_runner.WaitForJavaScriptCondition('this.becameIdle === true') | |
| 52 action_runner.ExecuteJavaScript( | |
| 53 'console.timeEnd({{ label }});', label=INTERACTION_NAME) | |
| 54 | |
| 55 | |
| 56 class TodoMVCPageSet(story.StorySet): | |
| 57 | |
| 58 """ TodoMVC examples """ | |
| 59 | |
| 60 def __init__(self): | |
| 61 super(TodoMVCPageSet, self).__init__( | |
| 62 archive_data_file='data/todomvc.json', | |
| 63 cloud_storage_bucket=story.PUBLIC_BUCKET) | |
| 64 | |
| 65 for name, url in URL_LIST: | |
| 66 self.AddStory(TodoMVCPage(url, self, name)) | |
| OLD | NEW |