| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
| 5 from telemetry import story | 5 from telemetry import story |
| 6 from page_sets.startup_pages import BrowserStartupSharedState | 6 from page_sets.startup_pages import BrowserStartupSharedState |
| 7 | 7 |
| 8 | 8 |
| 9 class BlankPage(page_module.Page): | 9 class BlankPage(page_module.Page): |
| 10 def __init__(self, url, page_set): | 10 def __init__(self, url, page_set, name): |
| 11 super(BlankPage, self).__init__(url, page_set=page_set) | 11 super(BlankPage, self).__init__(url, page_set=page_set, name=name) |
| 12 | 12 |
| 13 def RunPageInteractions(self, action_runner): | 13 def RunPageInteractions(self, action_runner): |
| 14 # Request a RAF and wait for it to be processed to ensure that the metric | 14 # Request a RAF and wait for it to be processed to ensure that the metric |
| 15 # Startup.FirstWebContents.NonEmptyPaint2 is recorded. | 15 # Startup.FirstWebContents.NonEmptyPaint2 is recorded. |
| 16 action_runner.ExecuteJavaScript( | 16 action_runner.ExecuteJavaScript( |
| 17 """ | 17 """ |
| 18 this.hasRunRAF = 0; | 18 this.hasRunRAF = 0; |
| 19 requestAnimationFrame(function() { | 19 requestAnimationFrame(function() { |
| 20 this.hasRunRAF = 1; | 20 this.hasRunRAF = 1; |
| 21 }); | 21 }); |
| 22 """ | 22 """ |
| 23 ) | 23 ) |
| 24 action_runner.WaitForJavaScriptCondition("this.hasRunRAF == 1") | 24 action_runner.WaitForJavaScriptCondition("this.hasRunRAF == 1") |
| 25 | 25 |
| 26 class BlankPageSet(story.StorySet): | 26 class BlankPageSet(story.StorySet): |
| 27 """A single blank page.""" | 27 """A single blank page.""" |
| 28 | 28 |
| 29 def __init__(self): | 29 def __init__(self): |
| 30 super(BlankPageSet, self).__init__() | 30 super(BlankPageSet, self).__init__(verify_names=True) |
| 31 self.AddStory(BlankPage('file://blank_page/blank_page.html', self)) | 31 self.AddStory(BlankPage('file://blank_page/blank_page.html', |
| 32 self, 'blank_page.html')) |
| 32 | 33 |
| 33 | 34 |
| 34 class BlankPageTBM(page_module.Page): | 35 class BlankPageTBM(page_module.Page): |
| 35 | 36 |
| 36 def __init__(self, url, page_set): | 37 def __init__(self, url, page_set): |
| 37 super(BlankPageTBM, self).__init__( | 38 super(BlankPageTBM, self).__init__( |
| 38 url, page_set=page_set, | 39 url, page_set=page_set, |
| 39 shared_page_state_class=BrowserStartupSharedState) | 40 shared_page_state_class=BrowserStartupSharedState) |
| 40 | 41 |
| 41 def RunPageInteractions(self, action_runner): | 42 def RunPageInteractions(self, action_runner): |
| 42 action_runner.ExecuteJavaScript( | 43 action_runner.ExecuteJavaScript( |
| 43 """ | 44 """ |
| 44 this.hasRunRAF = 0; | 45 this.hasRunRAF = 0; |
| 45 requestAnimationFrame(function() { | 46 requestAnimationFrame(function() { |
| 46 this.hasRunRAF = 1; | 47 this.hasRunRAF = 1; |
| 47 }); | 48 }); |
| 48 """ | 49 """ |
| 49 ) | 50 ) |
| 50 action_runner.WaitForJavaScriptCondition("this.hasRunRAF == 1") | 51 action_runner.WaitForJavaScriptCondition("this.hasRunRAF == 1") |
| 51 | 52 |
| 52 | 53 |
| 53 class BlankPageSetTBM(story.StorySet): | 54 class BlankPageSetTBM(story.StorySet): |
| 54 """A single blank page.""" | 55 """A single blank page.""" |
| 55 | 56 |
| 56 def __init__(self): | 57 def __init__(self): |
| 57 super(BlankPageSetTBM, self).__init__() | 58 super(BlankPageSetTBM, self).__init__() |
| 58 self.AddStory(BlankPageTBM('file://blank_page/blank_page.html', self)) | 59 self.AddStory(BlankPageTBM('file://blank_page/blank_page.html', self)) |
| OLD | NEW |