| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 import common | 5 import common |
| 6 from common import TestDriver | 6 from common import TestDriver |
| 7 from common import IntegrationTest | 7 from common import IntegrationTest |
| 8 | 8 |
| 9 | 9 |
| 10 class Video(IntegrationTest): | 10 class Video(IntegrationTest): |
| 11 | 11 |
| 12 # Check videos are proxied. | 12 # Check videos are proxied. |
| 13 def testCheckVideoHasViaHeader(self): | 13 def testCheckVideoHasViaHeader(self): |
| 14 with TestDriver() as t: | 14 with TestDriver() as t: |
| 15 t.AddChromeArg('--enable-spdy-proxy-auth') | 15 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 16 t.LoadURL( | 16 t.LoadURL( |
| 17 'http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html') | 17 'http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html') |
| 18 for response in t.GetHTTPResponses(): | 18 for response in t.GetHTTPResponses(): |
| 19 self.assertHasChromeProxyViaHeader(response) | 19 self.assertHasChromeProxyViaHeader(response) |
| 20 | 20 |
| 21 # Videos fetched via an XHR request should not be proxied. |
| 22 def testNoCompressionOnXHR(self): |
| 23 with TestDriver() as t: |
| 24 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 25 # The test will actually use Javascript, so use a site that won't have any |
| 26 # resources on it that could interfere. |
| 27 t.LoadURL('http://check.googlezip.net/connect') |
| 28 t.ExecuteJavascript( |
| 29 'var xhr = new XMLHttpRequest();' |
| 30 'xhr.open("GET", "/cacheable/video/data/buck_bunny_tiny.mp4", false);' |
| 31 'xhr.send();' |
| 32 'return;' |
| 33 ) |
| 34 saw_video_response = False |
| 35 for response in t.GetHTTPResponses(): |
| 36 if 'video' in response.response_headers['content-type']: |
| 37 self.assertNotHasChromeProxyViaHeader(response) |
| 38 saw_video_response = True |
| 39 else: |
| 40 self.assertHasChromeProxyViaHeader(response) |
| 41 self.assertTrue(saw_video_response, 'No video request seen in test!') |
| 42 |
| 21 if __name__ == '__main__': | 43 if __name__ == '__main__': |
| 22 IntegrationTest.RunAllTests() | 44 IntegrationTest.RunAllTests() |
| OLD | NEW |