| 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 HangCurrentThread(); |
| 203 base::WaitableEvent(false, false).Wait(); | |
| 204 return true; | 207 return true; |
| 205 } | 208 } |
| 206 | 209 |
| 210 if (url == GURL(kChromeUIDelayedBrowserUIHang)) { |
| 211 // Webdriver-safe url to hang the ui thread. Webdriver waits for the onload |
| 212 // event in javascript which needs a little more time to fire. |
| 213 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
| 214 base::Bind(&HangCurrentThread), |
| 215 base::TimeDelta::FromSeconds(2)); |
| 216 return true; |
| 217 } |
| 218 |
| 207 if (url == GURL(kChromeUIGpuCleanURL)) { | 219 if (url == GURL(kChromeUIGpuCleanURL)) { |
| 208 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | 220 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); |
| 209 if (shim) | 221 if (shim) |
| 210 shim->SimulateRemoveAllContext(); | 222 shim->SimulateRemoveAllContext(); |
| 211 return true; | 223 return true; |
| 212 } | 224 } |
| 213 | 225 |
| 214 if (url == GURL(kChromeUIGpuCrashURL)) { | 226 if (url == GURL(kChromeUIGpuCrashURL)) { |
| 215 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | 227 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); |
| 216 if (shim) | 228 if (shim) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 244 | 256 |
| 245 return url == GURL(kChromeUIBadCastCrashURL) || | 257 return url == GURL(kChromeUIBadCastCrashURL) || |
| 246 url == GURL(kChromeUICrashURL) || | 258 url == GURL(kChromeUICrashURL) || |
| 247 url == GURL(kChromeUIDumpURL) || | 259 url == GURL(kChromeUIDumpURL) || |
| 248 url == GURL(kChromeUIKillURL) || | 260 url == GURL(kChromeUIKillURL) || |
| 249 url == GURL(kChromeUIHangURL) || | 261 url == GURL(kChromeUIHangURL) || |
| 250 url == GURL(kChromeUIShorthangURL); | 262 url == GURL(kChromeUIShorthangURL); |
| 251 } | 263 } |
| 252 | 264 |
| 253 } // namespace content | 265 } // namespace content |
| OLD | NEW |