OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var util = {}; | 5 var util = {}; |
6 | 6 |
7 // Creates a <webview> tag in document.body and returns the reference to it. | 7 // Creates a <webview> tag in document.body and returns the reference to it. |
8 // It also sets a dummy src. The dummy src is significant because this makes | 8 // It also sets a dummy src. The dummy src is significant because this makes |
9 // sure that the <object> shim is created (asynchronously at this point) for the | 9 // sure that the <object> shim is created (asynchronously at this point) for the |
10 // <webview> tag. This makes the <webview> tag ready for add/removeEventListener | 10 // <webview> tag. This makes the <webview> tag ready for add/removeEventListener |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // loaded. | 402 // loaded. |
403 // TODO(fsamuel): Add a test to verify that subframe loads within a guest | 403 // TODO(fsamuel): Add a test to verify that subframe loads within a guest |
404 // do not fire the 'contentload' event. | 404 // do not fire the 'contentload' event. |
405 function webViewContentLoadEvent() { | 405 function webViewContentLoadEvent() { |
406 var webview = document.createElement('webview'); | 406 var webview = document.createElement('webview'); |
407 webview.addEventListener('contentload', function(e) { | 407 webview.addEventListener('contentload', function(e) { |
408 chrome.test.succeed(); | 408 chrome.test.succeed(); |
409 }); | 409 }); |
410 webview.setAttribute('src', 'data:text/html,trigger navigation'); | 410 webview.setAttribute('src', 'data:text/html,trigger navigation'); |
411 document.body.appendChild(webview); | 411 document.body.appendChild(webview); |
| 412 }, |
| 413 |
| 414 function webViewWebRequestAPI() { |
| 415 var webview = document.createElement('webview'); |
| 416 webview.setAttribute('src', 'data:text/html,trigger navigation'); |
| 417 var firstLoad = function() { |
| 418 webview.removeEventListener('loadstop', firstLoad); |
| 419 webview.onBeforeRequest.addListener(function(e) { |
| 420 chrome.test.succeed(); |
| 421 }, { urls: ['<all_urls>']}, ['blocking']) ; |
| 422 webview.src = windowOpenGuestURL; |
| 423 }; |
| 424 webview.addEventListener('loadstop', firstLoad); |
| 425 document.body.appendChild(webview); |
412 } | 426 } |
413 ]); | 427 ]); |
414 }); | 428 }); |
OLD | NEW |