Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / chrome_proxy / integration_tests / chrome_proxy_pagesets / block_once.py
blob07f0e0821f44c00ee60b9731f08168a3ada78d1d
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
3 # found in the LICENSE file.
5 from telemetry.page import page as page_module
6 from telemetry import story
9 class BlockOncePage(page_module.Page):
11 def __init__(self, url, page_set):
12 super(BlockOncePage, self).__init__(url=url, page_set=page_set)
14 def RunNavigateSteps(self, action_runner):
15 super(BlockOncePage, self).RunNavigateSteps(action_runner)
16 # Test block-once on a POST request.
17 # Ensure that a subsequent request uses the data reduction proxy.
18 action_runner.ExecuteJavaScript('''
19 (function() {
20 var request = new XMLHttpRequest();
21 request.open("POST",
22 "http://chromeproxy-test.appspot.com/default?respBody=T0s=&respStatus=200&flywheelAction=block-once");
23 request.onload = function() {
24 var viaProxyRequest = new XMLHttpRequest();
25 viaProxyRequest.open("GET",
26 "http://check.googlezip.net/image.png");
27 viaProxyRequest.send();
29 request.send();
30 })();
31 ''')
32 action_runner.Wait(1)
34 class BlockOnceStorySet(story.StorySet):
36 """ Chrome proxy test sites """
38 def __init__(self):
39 super(BlockOnceStorySet, self).__init__()
41 # Test block-once for a GET request.
42 urls_list = [
43 'http://check.googlezip.net/blocksingle/',
46 for url in urls_list:
47 self.AddStory(BlockOncePage(url, self))