| 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 | 4 |
| 5 from telemetry.page import page as page_module | 5 from telemetry.page import page as page_module |
| 6 from telemetry.page import page_set as page_set_module | 6 from telemetry.story import story_set as story_set_module |
| 7 | 7 |
| 8 | 8 |
| 9 class BlockOncePage(page_module.Page): | 9 class BlockOncePage(page_module.Page): |
| 10 | 10 |
| 11 def __init__(self, url, page_set): | 11 def __init__(self, url, page_set): |
| 12 super(BlockOncePage, self).__init__(url=url, page_set=page_set) | 12 super(BlockOncePage, self).__init__(url=url, page_set=page_set) |
| 13 | 13 |
| 14 def RunNavigateSteps(self, action_runner): | 14 def RunNavigateSteps(self, action_runner): |
| 15 super(BlockOncePage, self).RunNavigateSteps(action_runner) | 15 super(BlockOncePage, self).RunNavigateSteps(action_runner) |
| 16 # Test block-once on a POST request. | 16 # Test block-once on a POST request. |
| 17 # Ensure that a subsequent request uses the data reduction proxy. | 17 # Ensure that a subsequent request uses the data reduction proxy. |
| 18 action_runner.ExecuteJavaScript(''' | 18 action_runner.ExecuteJavaScript(''' |
| 19 (function() { | 19 (function() { |
| 20 var request = new XMLHttpRequest(); | 20 var request = new XMLHttpRequest(); |
| 21 request.open("POST", | 21 request.open("POST", |
| 22 "http://chromeproxy-test.appspot.com/default?respBody=T0s=&respStatu
s=200&flywheelAction=block-once"); | 22 "http://chromeproxy-test.appspot.com/default?respBody=T0s=&respStatu
s=200&flywheelAction=block-once"); |
| 23 request.onload = function() { | 23 request.onload = function() { |
| 24 var viaProxyRequest = new XMLHttpRequest(); | 24 var viaProxyRequest = new XMLHttpRequest(); |
| 25 viaProxyRequest.open("GET", | 25 viaProxyRequest.open("GET", |
| 26 "http://check.googlezip.net/image.png"); | 26 "http://check.googlezip.net/image.png"); |
| 27 viaProxyRequest.send(); | 27 viaProxyRequest.send(); |
| 28 }; | 28 }; |
| 29 request.send(); | 29 request.send(); |
| 30 })(); | 30 })(); |
| 31 ''') | 31 ''') |
| 32 action_runner.Wait(1) | 32 action_runner.Wait(1) |
| 33 | 33 |
| 34 class BlockOncePageSet(page_set_module.PageSet): | 34 class BlockOnceStorySet(story_set_module.StorySet): |
| 35 | 35 |
| 36 """ Chrome proxy test sites """ | 36 """ Chrome proxy test sites """ |
| 37 | 37 |
| 38 def __init__(self): | 38 def __init__(self): |
| 39 super(BlockOncePageSet, self).__init__() | 39 super(BlockOnceStorySet, self).__init__() |
| 40 | 40 |
| 41 # Test block-once for a GET request. | 41 # Test block-once for a GET request. |
| 42 urls_list = [ | 42 urls_list = [ |
| 43 'http://check.googlezip.net/blocksingle/', | 43 'http://check.googlezip.net/blocksingle/', |
| 44 ] | 44 ] |
| 45 | 45 |
| 46 for url in urls_list: | 46 for url in urls_list: |
| 47 self.AddUserStory(BlockOncePage(url, self)) | 47 self.AddStory(BlockOncePage(url, self)) |
| OLD | NEW |