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 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 webview.loadDataWithBaseUrl("data:text/html;base64,PGh0bWw+CiAgVGhpcyBpcy" + | 2025 webview.loadDataWithBaseUrl("data:text/html;base64,PGh0bWw+CiAgVGhpcyBpcy" + |
2026 "BhIHRlc3QuPGJyPgogIDxpbWcgc3JjPSJ0ZXN0LmJtcCI+PGJyPgo8L2h0bWw+Cg==", | 2026 "BhIHRlc3QuPGJyPgogIDxpbWcgc3JjPSJ0ZXN0LmJtcCI+PGJyPgo8L2h0bWw+Cg==", |
2027 embedder.testImageBaseURL, | 2027 embedder.testImageBaseURL, |
2028 embedder.virtualURL); | 2028 embedder.virtualURL); |
2029 } | 2029 } |
2030 | 2030 |
2031 webview.addEventListener('loadstop', loadstopListener1); | 2031 webview.addEventListener('loadstop', loadstopListener1); |
2032 document.body.appendChild(webview); | 2032 document.body.appendChild(webview); |
2033 }; | 2033 }; |
2034 | 2034 |
| 2035 // Test that the resize events fire with the correct values, and in the |
| 2036 // correct order, when resizing occurs. |
| 2037 function testResizeEvents() { |
| 2038 var webview = new WebView(); |
| 2039 webview.src = 'about:blank'; |
| 2040 webview.style.width = '600px'; |
| 2041 webview.style.height = '400px'; |
| 2042 |
| 2043 var checkSizes = function(e) { |
| 2044 embedder.test.assertEq(e.oldWidth, 600) |
| 2045 embedder.test.assertEq(e.oldHeight, 400) |
| 2046 embedder.test.assertEq(e.newWidth, 500) |
| 2047 embedder.test.assertEq(e.newHeight, 400) |
| 2048 } |
| 2049 |
| 2050 var resizeListener = function(e) { |
| 2051 webview.onresize = null; |
| 2052 webview.oncontentresize = contentResizeListener; |
| 2053 |
| 2054 console.log('onresize'); |
| 2055 checkSizes(e); |
| 2056 }; |
| 2057 |
| 2058 var contentResizeListener = function(e) { |
| 2059 webview.oncontentresize = null; |
| 2060 |
| 2061 console.log('oncontentresize'); |
| 2062 checkSizes(e); |
| 2063 embedder.test.succeed(); |
| 2064 }; |
| 2065 |
| 2066 var loadstopListener = function(e) { |
| 2067 webview.removeEventListener('loadstop', loadstopListener); |
| 2068 webview.onresize = resizeListener; |
| 2069 |
| 2070 console.log('Resizing <webview> width from 600px to 500px.'); |
| 2071 webview.style.width = '500px'; |
| 2072 } |
| 2073 |
| 2074 webview.addEventListener('loadstop', loadstopListener); |
| 2075 document.body.appendChild(webview); |
| 2076 }; |
| 2077 |
2035 embedder.test.testList = { | 2078 embedder.test.testList = { |
2036 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, | 2079 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, |
2037 'testAutosizeHeight': testAutosizeHeight, | 2080 'testAutosizeHeight': testAutosizeHeight, |
2038 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, | 2081 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
2039 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, | 2082 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
2040 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, | 2083 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, |
2041 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, | 2084 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, |
2042 'testAPIMethodExistence': testAPIMethodExistence, | 2085 'testAPIMethodExistence': testAPIMethodExistence, |
2043 'testChromeExtensionURL': testChromeExtensionURL, | 2086 'testChromeExtensionURL': testChromeExtensionURL, |
2044 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, | 2087 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, | 2144 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, |
2102 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, | 2145 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, |
2103 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, | 2146 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, |
2104 'testResizeWebviewWithDisplayNoneResizesContent': | 2147 'testResizeWebviewWithDisplayNoneResizesContent': |
2105 testResizeWebviewWithDisplayNoneResizesContent, | 2148 testResizeWebviewWithDisplayNoneResizesContent, |
2106 'testPostMessageCommChannel': testPostMessageCommChannel, | 2149 'testPostMessageCommChannel': testPostMessageCommChannel, |
2107 'testScreenshotCapture' : testScreenshotCapture, | 2150 'testScreenshotCapture' : testScreenshotCapture, |
2108 'testZoomAPI' : testZoomAPI, | 2151 'testZoomAPI' : testZoomAPI, |
2109 'testFindAPI': testFindAPI, | 2152 'testFindAPI': testFindAPI, |
2110 'testFindAPI_findupdate': testFindAPI, | 2153 'testFindAPI_findupdate': testFindAPI, |
2111 'testLoadDataAPI': testLoadDataAPI | 2154 'testLoadDataAPI': testLoadDataAPI, |
| 2155 'testResizeEvents': testResizeEvents |
2112 }; | 2156 }; |
2113 | 2157 |
2114 onload = function() { | 2158 onload = function() { |
2115 chrome.test.getConfig(function(config) { | 2159 chrome.test.getConfig(function(config) { |
2116 embedder.setUp_(config); | 2160 embedder.setUp_(config); |
2117 chrome.test.sendMessage("Launched"); | 2161 chrome.test.sendMessage("Launched"); |
2118 }); | 2162 }); |
2119 }; | 2163 }; |
OLD | NEW |