| 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 #include "content/browser/frame_host/debug_urls.h" | 5 #include "content/browser/frame_host/debug_urls.h" |
| 6 | 6 |
| 7 #if defined(SYZYASAN) | 7 #if defined(SYZYASAN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
| 25 #include "third_party/kasko/kasko_features.h" | 25 #include "third_party/kasko/kasko_features.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 #if defined(ENABLE_PLUGINS) | 28 #if defined(ENABLE_PLUGINS) |
| 29 #include "content/browser/ppapi_plugin_process_host.h" | 29 #include "content/browser/ppapi_plugin_process_host.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 | 33 |
| 34 class ScopedAllowWaitForDebugURL { |
| 35 private: |
| 36 base::ThreadRestrictions::ScopedAllowWait wait; |
| 37 }; |
| 38 |
| 34 namespace { | 39 namespace { |
| 35 | 40 |
| 36 // Define the Asan debug URLs. | 41 // Define the Asan debug URLs. |
| 37 const char kAsanCrashDomain[] = "crash"; | 42 const char kAsanCrashDomain[] = "crash"; |
| 38 const char kAsanHeapOverflow[] = "/browser-heap-overflow"; | 43 const char kAsanHeapOverflow[] = "/browser-heap-overflow"; |
| 39 const char kAsanHeapUnderflow[] = "/browser-heap-underflow"; | 44 const char kAsanHeapUnderflow[] = "/browser-heap-underflow"; |
| 40 const char kAsanUseAfterFree[] = "/browser-use-after-free"; | 45 const char kAsanUseAfterFree[] = "/browser-use-after-free"; |
| 41 #if defined(SYZYASAN) | 46 #if defined(SYZYASAN) |
| 42 const char kAsanCorruptHeapBlock[] = "/browser-corrupt-heap-block"; | 47 const char kAsanCorruptHeapBlock[] = "/browser-corrupt-heap-block"; |
| 43 const char kAsanCorruptHeap[] = "/browser-corrupt-heap"; | 48 const char kAsanCorruptHeap[] = "/browser-corrupt-heap"; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } else if (url.path() == kAsanUseAfterFree) { | 162 } else if (url.path() == kAsanUseAfterFree) { |
| 158 base::debug::AsanHeapUseAfterFree(); | 163 base::debug::AsanHeapUseAfterFree(); |
| 159 } else { | 164 } else { |
| 160 return false; | 165 return false; |
| 161 } | 166 } |
| 162 #endif | 167 #endif |
| 163 | 168 |
| 164 return true; | 169 return true; |
| 165 } | 170 } |
| 166 | 171 |
| 172 void HangCurrentThread() { |
| 173 ScopedAllowWaitForDebugURL allow_wait; |
| 174 base::WaitableEvent(false, false).Wait(); |
| 175 } |
| 167 | 176 |
| 168 } // namespace | 177 } // namespace |
| 169 | 178 |
| 170 class ScopedAllowWaitForDebugURL { | |
| 171 private: | |
| 172 base::ThreadRestrictions::ScopedAllowWait wait; | |
| 173 }; | |
| 174 | |
| 175 bool HandleDebugURL(const GURL& url, ui::PageTransition transition) { | 179 bool HandleDebugURL(const GURL& url, ui::PageTransition transition) { |
| 176 // Ensure that the user explicitly navigated to this URL, unless | 180 // Ensure that the user explicitly navigated to this URL, unless |
| 177 // kEnableGpuBenchmarking is enabled by Telemetry. | 181 // kEnableGpuBenchmarking is enabled by Telemetry. |
| 178 bool is_telemetry_navigation = | 182 bool is_telemetry_navigation = |
| 179 base::CommandLine::ForCurrentProcess()->HasSwitch( | 183 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 180 cc::switches::kEnableGpuBenchmarking) && | 184 cc::switches::kEnableGpuBenchmarking) && |
| 181 (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED)); | 185 (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED)); |
| 182 | 186 |
| 183 if (!(transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) && | 187 if (!(transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) && |
| 184 !is_telemetry_navigation) | 188 !is_telemetry_navigation) |
| 185 return false; | 189 return false; |
| 186 | 190 |
| 187 if (IsAsanDebugURL(url)) | 191 if (IsAsanDebugURL(url)) |
| 188 return HandleAsanDebugURL(url); | 192 return HandleAsanDebugURL(url); |
| 189 | 193 |
| 190 if (IsKaskoDebugURL(url)) { | 194 if (IsKaskoDebugURL(url)) { |
| 191 HandleKaskoDebugURL(); | 195 HandleKaskoDebugURL(); |
| 192 return true; | 196 return true; |
| 193 } | 197 } |
| 194 | 198 |
| 195 if (url == GURL(kChromeUIBrowserCrashURL)) { | 199 if (url == GURL(kChromeUIBrowserCrashURL)) { |
| 196 // Induce an intentional crash in the browser process. | 200 // Induce an intentional crash in the browser process. |
| 197 CHECK(false); | 201 CHECK(false); |
| 198 return true; | 202 return true; |
| 199 } | 203 } |
| 200 | 204 |
| 201 if (url == GURL(kChromeUIBrowserUIHang)) { | 205 if (url == GURL(kChromeUIBrowserUIHang)) { |
| 202 ScopedAllowWaitForDebugURL allow_wait; | 206 // Webdriver waits for the onload event in javascript which needs a little |
| 203 base::WaitableEvent(false, false).Wait(); | 207 // more time to fire. |
| 208 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
| 209 base::Bind(&HangCurrentThread), |
| 210 base::TimeDelta::FromSeconds(1)); |
| 204 return true; | 211 return true; |
| 205 } | 212 } |
| 206 | 213 |
| 207 if (url == GURL(kChromeUIGpuCleanURL)) { | 214 if (url == GURL(kChromeUIGpuCleanURL)) { |
| 208 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | 215 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); |
| 209 if (shim) | 216 if (shim) |
| 210 shim->SimulateRemoveAllContext(); | 217 shim->SimulateRemoveAllContext(); |
| 211 return true; | 218 return true; |
| 212 } | 219 } |
| 213 | 220 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 244 | 251 |
| 245 return url == GURL(kChromeUIBadCastCrashURL) || | 252 return url == GURL(kChromeUIBadCastCrashURL) || |
| 246 url == GURL(kChromeUICrashURL) || | 253 url == GURL(kChromeUICrashURL) || |
| 247 url == GURL(kChromeUIDumpURL) || | 254 url == GURL(kChromeUIDumpURL) || |
| 248 url == GURL(kChromeUIKillURL) || | 255 url == GURL(kChromeUIKillURL) || |
| 249 url == GURL(kChromeUIHangURL) || | 256 url == GURL(kChromeUIHangURL) || |
| 250 url == GURL(kChromeUIShorthangURL); | 257 url == GURL(kChromeUIShorthangURL); |
| 251 } | 258 } |
| 252 | 259 |
| 253 } // namespace content | 260 } // namespace content |
| OLD | NEW |