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 var embedder = {}; | 6 var embedder = {}; |
7 embedder.baseGuestURL = ''; | 7 embedder.baseGuestURL = ''; |
8 embedder.emptyGuestURL = ''; | 8 embedder.emptyGuestURL = ''; |
9 embedder.windowOpenGuestURL = ''; | 9 embedder.windowOpenGuestURL = ''; |
10 embedder.noReferrerGuestURL = ''; | 10 embedder.noReferrerGuestURL = ''; |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 ] | 977 ] |
978 }; | 978 }; |
979 webview.request.onRequest.addRules([rule]); | 979 webview.request.onRequest.addRules([rule]); |
980 webview.addEventListener('loadabort', function(e) { | 980 webview.addEventListener('loadabort', function(e) { |
981 embedder.test.assertEq(1, step); | 981 embedder.test.assertEq(1, step); |
982 embedder.test.assertEq('ERR_BLOCKED_BY_CLIENT', e.reason); | 982 embedder.test.assertEq('ERR_BLOCKED_BY_CLIENT', e.reason); |
983 step = 2; | 983 step = 2; |
984 webview.request.onRequest.removeRules(); | 984 webview.request.onRequest.removeRules(); |
985 webview.reload(); | 985 webview.reload(); |
986 }); | 986 }); |
987 webview.addEventListener('loadcommit', function(e) { | 987 webview.addEventListener('loadstop', function(e) { |
988 embedder.test.assertEq(2, step); | 988 embedder.test.assertEq(2, step); |
989 embedder.test.succeed(); | 989 embedder.test.succeed(); |
990 }); | 990 }); |
991 webview.src = embedder.emptyGuestURL; | 991 webview.src = embedder.emptyGuestURL; |
992 document.body.appendChild(webview); | 992 document.body.appendChild(webview); |
993 } | 993 } |
994 | 994 |
| 995 function testDeclarativeWebRequestAPISendMessage() { |
| 996 var webview = new WebView(); |
| 997 window.console.log(embedder.emptyGuestURL); |
| 998 var rule = { |
| 999 conditions: [ |
| 1000 new chrome.webViewRequest.RequestMatcher( |
| 1001 { |
| 1002 url: { urlContains: 'guest' } |
| 1003 } |
| 1004 ) |
| 1005 ], |
| 1006 actions: [ |
| 1007 new chrome.webViewRequest.SendMessageToExtension({ message: 'bleep' }) |
| 1008 ] |
| 1009 }; |
| 1010 webview.request.onRequest.addRules([rule]); |
| 1011 webview.request.onMessage.addListener(function(e) { |
| 1012 embedder.test.assertEq('bleep', e.message); |
| 1013 embedder.test.succeed(); |
| 1014 }); |
| 1015 webview.src = embedder.emptyGuestURL; |
| 1016 document.body.appendChild(webview); |
| 1017 } |
| 1018 |
995 // This test verifies that the WebRequest API onBeforeRequest event fires on | 1019 // This test verifies that the WebRequest API onBeforeRequest event fires on |
996 // clients*.google.com URLs. | 1020 // clients*.google.com URLs. |
997 function testWebRequestAPIGoogleProperty() { | 1021 function testWebRequestAPIGoogleProperty() { |
998 var webview = new WebView(); | 1022 var webview = new WebView(); |
999 webview.request.onBeforeRequest.addListener(function(e) { | 1023 webview.request.onBeforeRequest.addListener(function(e) { |
1000 embedder.test.succeed(); | 1024 embedder.test.succeed(); |
1001 return {cancel: true}; | 1025 return {cancel: true}; |
1002 }, { urls: ['<all_urls>']}, ['blocking']) ; | 1026 }, { urls: ['<all_urls>']}, ['blocking']) ; |
1003 webview.src = 'http://clients6.google.com'; | 1027 webview.src = 'http://clients6.google.com'; |
1004 document.body.appendChild(webview); | 1028 document.body.appendChild(webview); |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 'testReassignSrcAttribute': testReassignSrcAttribute, | 1696 'testReassignSrcAttribute': testReassignSrcAttribute, |
1673 'testRemoveSrcAttribute': testRemoveSrcAttribute, | 1697 'testRemoveSrcAttribute': testRemoveSrcAttribute, |
1674 'testBrowserPluginNotAllowed': testBrowserPluginNotAllowed, | 1698 'testBrowserPluginNotAllowed': testBrowserPluginNotAllowed, |
1675 'testPluginLoadPermission': testPluginLoadPermission, | 1699 'testPluginLoadPermission': testPluginLoadPermission, |
1676 'testNewWindow': testNewWindow, | 1700 'testNewWindow': testNewWindow, |
1677 'testNewWindowTwoListeners': testNewWindowTwoListeners, | 1701 'testNewWindowTwoListeners': testNewWindowTwoListeners, |
1678 'testNewWindowNoPreventDefault': testNewWindowNoPreventDefault, | 1702 'testNewWindowNoPreventDefault': testNewWindowNoPreventDefault, |
1679 'testNewWindowNoReferrerLink': testNewWindowNoReferrerLink, | 1703 'testNewWindowNoReferrerLink': testNewWindowNoReferrerLink, |
1680 'testContentLoadEvent': testContentLoadEvent, | 1704 'testContentLoadEvent': testContentLoadEvent, |
1681 'testDeclarativeWebRequestAPI': testDeclarativeWebRequestAPI, | 1705 'testDeclarativeWebRequestAPI': testDeclarativeWebRequestAPI, |
| 1706 'testDeclarativeWebRequestAPISendMessage': |
| 1707 testDeclarativeWebRequestAPISendMessage, |
1682 'testWebRequestAPI': testWebRequestAPI, | 1708 'testWebRequestAPI': testWebRequestAPI, |
1683 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty, | 1709 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty, |
1684 'testWebRequestListenerSurvivesReparenting': | 1710 'testWebRequestListenerSurvivesReparenting': |
1685 testWebRequestListenerSurvivesReparenting, | 1711 testWebRequestListenerSurvivesReparenting, |
1686 'testGetProcessId': testGetProcessId, | 1712 'testGetProcessId': testGetProcessId, |
1687 'testHiddenBeforeNavigation': testHiddenBeforeNavigation, | 1713 'testHiddenBeforeNavigation': testHiddenBeforeNavigation, |
1688 'testLoadStartLoadRedirect': testLoadStartLoadRedirect, | 1714 'testLoadStartLoadRedirect': testLoadStartLoadRedirect, |
1689 'testLoadAbortChromeExtensionURLWrongPartition': | 1715 'testLoadAbortChromeExtensionURLWrongPartition': |
1690 testLoadAbortChromeExtensionURLWrongPartition, | 1716 testLoadAbortChromeExtensionURLWrongPartition, |
1691 'testLoadAbortEmptyResponse': testLoadAbortEmptyResponse, | 1717 'testLoadAbortEmptyResponse': testLoadAbortEmptyResponse, |
(...skipping 14 matching lines...) Expand all Loading... |
1706 'testFindAPI': testFindAPI, | 1732 'testFindAPI': testFindAPI, |
1707 'testFindAPI_findupdate': testFindAPI | 1733 'testFindAPI_findupdate': testFindAPI |
1708 }; | 1734 }; |
1709 | 1735 |
1710 onload = function() { | 1736 onload = function() { |
1711 chrome.test.getConfig(function(config) { | 1737 chrome.test.getConfig(function(config) { |
1712 embedder.setUp_(config); | 1738 embedder.setUp_(config); |
1713 chrome.test.sendMessage("Launched"); | 1739 chrome.test.sendMessage("Launched"); |
1714 }); | 1740 }); |
1715 }; | 1741 }; |
OLD | NEW |