OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 fnmatch | 5 import fnmatch |
6 import urlparse | 6 import urlparse |
7 | 7 |
8 # Valid expectation conditions are: | 8 # Valid expectation conditions are: |
9 # | 9 # |
10 # Operating systems: | 10 # Operating systems: |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 # For compatibility, the file:// scheme must be treated specially. | 158 # For compatibility, the file:// scheme must be treated specially. |
159 # The top-level directory shows up in the netloc portion of the URL. | 159 # The top-level directory shows up in the netloc portion of the URL. |
160 if components[0] == 'file': | 160 if components[0] == 'file': |
161 url_path = components[1] + components[2] | 161 url_path = components[1] + components[2] |
162 else: | 162 else: |
163 url_path = components[2] | 163 url_path = components[2] |
164 # Chop any leading slash since the expectations used by this class | 164 # Chop any leading slash since the expectations used by this class |
165 # assume that. | 165 # assume that. |
166 if (url_path and url_path[0] == '/'): | 166 if (url_path and url_path[0] == '/'): |
167 url_path = url_path[1:] | 167 url_path = url_path[1:] |
| 168 # Python's urlsplit doesn't seem to handle query arguments for |
| 169 # file:// URLs properly. Split them off manually. |
| 170 query_index = url_path.find('?') |
| 171 if query_index > 0: |
| 172 url_path = url_path[0:query_index] |
168 return url_path | 173 return url_path |
169 | 174 |
170 def _GetExpectationObjectForPage(self, browser, page): | 175 def _GetExpectationObjectForPage(self, browser, page): |
171 if not self._built_expectation_cache: | 176 if not self._built_expectation_cache: |
172 self._BuildExpectationsCache(browser, page) | 177 self._BuildExpectationsCache(browser, page) |
173 # First attempt to look up by the page's URL or name. | 178 # First attempt to look up by the page's URL or name. |
174 e = None | 179 e = None |
175 # Relative URL (common case). | 180 # Relative URL (common case). |
176 url = self._GetNormalizedURL(page.url, browser) | 181 url = self._GetNormalizedURL(page.url, browser) |
177 url_path = self._GetURLPath(url) | 182 url_path = self._GetURLPath(url) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 platform = browser.platform | 243 platform = browser.platform |
239 os_matches = (not expectation.os_conditions or | 244 os_matches = (not expectation.os_conditions or |
240 platform.GetOSName() in expectation.os_conditions or | 245 platform.GetOSName() in expectation.os_conditions or |
241 platform.GetOSVersionName() in expectation.os_conditions) | 246 platform.GetOSVersionName() in expectation.os_conditions) |
242 | 247 |
243 browser_matches = ( | 248 browser_matches = ( |
244 (not expectation.browser_conditions) or | 249 (not expectation.browser_conditions) or |
245 browser.browser_type in expectation.browser_conditions) | 250 browser.browser_type in expectation.browser_conditions) |
246 | 251 |
247 return os_matches and browser_matches | 252 return os_matches and browser_matches |
OLD | NEW |