diff options
author | lazyboy <lazyboy@chromium.org> | 2015-05-21 20:56:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-22 03:56:34 +0000 |
commit | 02d983c9d55e2f93b5b370a403cb1ff36c22cef0 (patch) | |
tree | e2d4214f930aa451762935987e2131e8be3795d2 | |
parent | 93c46cf417786f10d88c7153993370b1610c56b8 (diff) | |
download | chromium_src-02d983c9d55e2f93b5b370a403cb1ff36c22cef0.zip chromium_src-02d983c9d55e2f93b5b370a403cb1ff36c22cef0.tar.gz chromium_src-02d983c9d55e2f93b5b370a403cb1ff36c22cef0.tar.bz2 |
Add a basic postMessage test for <webview> in a new test suite.
The plan is to run this test in site isolation bots as well when
<webview> using OOPIF CL lands.
BUG=330264
Test=None
Review URL: https://codereview.chromium.org/1148903003
Cr-Commit-Position: refs/heads/master@{#331061}
7 files changed, 103 insertions, 2 deletions
diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc index b81f521..faa272a 100644 --- a/chrome/browser/apps/guest_view/web_view_browsertest.cc +++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc @@ -843,6 +843,10 @@ class WebViewTest : public extensions::PlatformAppBrowserTest { content::WebContents* embedder_web_contents_; }; +// Test suite that containts tests that are meant to run with and without +// --site-per-process. +class WebViewCommonTest : public extensions::PlatformAppBrowserTest {}; + class WebViewDPITest : public WebViewTest { protected: void SetUpCommandLine(base::CommandLine* command_line) override { @@ -2717,3 +2721,9 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, AllowTransparencyAndAllowScalingPropagate) { ASSERT_TRUE(guest->allow_transparency()); ASSERT_TRUE(guest->allow_scaling()); } + +IN_PROC_BROWSER_TEST_F(WebViewCommonTest, BasicPostMessage) { + ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. + ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/post_message/basic")) + << message_; +} diff --git a/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/embedder.html b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/embedder.html new file mode 100644 index 0000000..9fbd750e --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/embedder.html @@ -0,0 +1,13 @@ +<!-- + * Copyright 2015 The Chromium Authors. All rights reserved. Use of this + * source code is governed by a BSD-style license that can be found in the + * LICENSE file. +--> +<html> +<head> +</head> +<body> + <div id="webview-tag-container"></div> + <script src="embedder.js"></script> +</body> +</html> diff --git a/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/embedder.js b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/embedder.js new file mode 100644 index 0000000..89f60d9 --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/embedder.js @@ -0,0 +1,49 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var webview = null; + +var LOG = function(msg) { + window.console.log(msg); +}; + +var startTest = function(guestURL) { + window.onmessage = onMessage; + chrome.test.sendMessage('guest-loaded'); + webview = document.getElementById('webview'); + webview.onloadstop = onWebviewLoaded; + webview.onconsolemessage = function(e) { LOG('[Guest]: ' + e.message); }; + + webview.setAttribute('src', guestURL); +}; + +var onWebviewLoaded = function(event) { + LOG('onWebviewLoaded'); + webview.contentWindow.postMessage(JSON.stringify(['ping']), '*'); +}; + +var onMessage = function(e) { + var data = JSON.parse(e.data); + if (data.length != 1 || data[0] !== 'pong') { + LOG('Unexpected data received from webview.'); + chrome.test.fail(); + } else if (e.source != webview.contentWindow) { + LOG('wrong event.source in postMessage'); + chrome.test.fail(); + } else { + chrome.test.succeed(); + } +}; + +chrome.test.getConfig(function(config) { + chrome.test.runTests([ + function postMessage() { + var guestURL = 'http://localhost:' + config.testServer.port + + '/extensions/platform_apps/web_view/post_message/basic/guest.html'; + LOG('guestURL: ' + guestURL); + document.querySelector('#webview-tag-container').innerHTML = + '<webview id="webview"></webview>'; + startTest(guestURL); + }]); +}); diff --git a/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/guest.html b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/guest.html new file mode 100644 index 0000000..838bbe7 --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/guest.html @@ -0,0 +1,14 @@ +<!-- + * Copyright 2015 The Chromium Authors. All rights reserved. Use of this + * source code is governed by a BSD-style license that can be found in the + * LICENSE file. +--> +<script> +window.addEventListener('message', function(e) { + window.console.log('post message received.'); + var data = JSON.parse(e.data); + if (data.length == 1 && data[0] === 'ping') { + e.source.postMessage(JSON.stringify(['pong']), '*'); + } +}); +</script> diff --git a/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/manifest.json b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/manifest.json new file mode 100644 index 0000000..7a90b2c --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "Platform App Test: <webview> basic postMessage", + "version": "1", + "permissions": ["webview"], + "app": { + "background": {"scripts": ["test.js"]} + } +} diff --git a/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/test.js b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/test.js new file mode 100644 index 0000000..0c660a6 --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/test.js @@ -0,0 +1,7 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +chrome.app.runtime.onLaunched.addListener(function() { + chrome.app.window.create('embedder.html', {}, function () {}); +}); diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 208aeaa..80a2a39 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json @@ -2678,7 +2678,7 @@ { "args": [ "--site-per-process", - "--gtest_filter=-AppApiTest.*:BlockedAppApiTest.*:BrowserTest.ClearPendingOnFailUnlessNTP:BrowserTest.OtherRedirectsDontForkProcess:BrowserTest.WindowOpenClose:ChromeAppAPITest.*:ChromeRenderProcessHostTest.*:ChromeRenderProcessHostTestWithCommandLine.*:DevToolsExperimentalExtensionTest.*:DevToolsExtensionTest.*:DnsProbeBrowserTest.*:ErrorPageTest.*:ExecuteScriptApiTest.ExecuteScriptPermissions:ExtensionApiTest.ActiveTab:ExtensionApiTest.ChromeRuntimeOpenOptionsPage:ExtensionApiTest.ContentScriptExtensionIframe:ExtensionApiTest.ContentScriptOtherExtensions:ExtensionApiTest.ContentScriptExtensionProcess:ExtensionApiTest.Tabs2:ExtensionApiTest.TabsOnUpdated:ExtensionApiTest.WindowOpenPopupIframe:ExtensionBrowserTest.LoadChromeExtensionsWithOptionsParamWhenEmbedded:ExtensionCrxInstallerTest.InstallDelayedUntilNextUpdate:ExtensionOptionsApiTest.ExtensionCanEmbedOwnOptions:ExtensionWebUITest.CanEmbedExtensionOptions:ExtensionWebUITest.ReceivesExtensionOptionsOnClose:InlineLoginUISafeIframeBrowserTest.*:IsolatedAppTest.*:LaunchWebAuthFlowFunctionTest.*:MimeHandlerViewTest.*:*.NewAvatarMenuEnabledInGuestMode:OptionsUIBrowserTest.*:*PDFExtensionTest.Load*:PhishingClassifierTest.*:PhishingDOMFeatureExtractorTest.*:PlatformAppUrlRedirectorBrowserTest.*:PopupBlockerBrowserTest.*:PrerenderBrowserTest.*:ProcessManagementTest.*:RedirectTest.*:ReferrerPolicyTest.*:SSLUITest.*:WebNavigationApiTest.CrossProcessFragment:WebNavigationApiTest.ServerRedirectSingleProcess:WebNavigationApiTest.CrossProcessHistory:WebViewDPITest.*:WebViewPluginTest.*:WebViewTest.*:ZoomControllerBrowserTest.*:*.NavigateFromNTPToOptionsInSameTab:*.ProfilesWithoutPagesNotLaunched:*.TabMove:*.WhitelistedExtension:*.NewTabPageURL:*.HomepageLocation:RestoreOnStartupPolicyTest*:PhishingClassifierDelegateTest.*:WebUIWebViewBrowserTest*" + "--gtest_filter=-AppApiTest.*:BlockedAppApiTest.*:BrowserTest.ClearPendingOnFailUnlessNTP:BrowserTest.OtherRedirectsDontForkProcess:BrowserTest.WindowOpenClose:ChromeAppAPITest.*:ChromeRenderProcessHostTest.*:ChromeRenderProcessHostTestWithCommandLine.*:DevToolsExperimentalExtensionTest.*:DevToolsExtensionTest.*:DnsProbeBrowserTest.*:ErrorPageTest.*:ExecuteScriptApiTest.ExecuteScriptPermissions:ExtensionApiTest.ActiveTab:ExtensionApiTest.ChromeRuntimeOpenOptionsPage:ExtensionApiTest.ContentScriptExtensionIframe:ExtensionApiTest.ContentScriptOtherExtensions:ExtensionApiTest.ContentScriptExtensionProcess:ExtensionApiTest.Tabs2:ExtensionApiTest.TabsOnUpdated:ExtensionApiTest.WindowOpenPopupIframe:ExtensionBrowserTest.LoadChromeExtensionsWithOptionsParamWhenEmbedded:ExtensionCrxInstallerTest.InstallDelayedUntilNextUpdate:ExtensionOptionsApiTest.ExtensionCanEmbedOwnOptions:ExtensionWebUITest.CanEmbedExtensionOptions:ExtensionWebUITest.ReceivesExtensionOptionsOnClose:InlineLoginUISafeIframeBrowserTest.*:IsolatedAppTest.*:LaunchWebAuthFlowFunctionTest.*:MimeHandlerViewTest.*:*.NewAvatarMenuEnabledInGuestMode:OptionsUIBrowserTest.*:*PDFExtensionTest.Load*:PhishingClassifierTest.*:PhishingDOMFeatureExtractorTest.*:PlatformAppUrlRedirectorBrowserTest.*:PopupBlockerBrowserTest.*:PrerenderBrowserTest.*:ProcessManagementTest.*:RedirectTest.*:ReferrerPolicyTest.*:SSLUITest.*:WebNavigationApiTest.CrossProcessFragment:WebNavigationApiTest.ServerRedirectSingleProcess:WebNavigationApiTest.CrossProcessHistory:WebViewCommonTest.*:WebViewDPITest.*:WebViewPluginTest.*:WebViewTest.*:ZoomControllerBrowserTest.*:*.NavigateFromNTPToOptionsInSameTab:*.ProfilesWithoutPagesNotLaunched:*.TabMove:*.WhitelistedExtension:*.NewTabPageURL:*.HomepageLocation:RestoreOnStartupPolicyTest*:PhishingClassifierDelegateTest.*:WebUIWebViewBrowserTest*" ], "test": "browser_tests" }, @@ -2708,7 +2708,7 @@ { "args": [ "--site-per-process", - "--gtest_filter=-AppApiTest.*:BlockedAppApiTest.*:BrowserTest.ClearPendingOnFailUnlessNTP:BrowserTest.OtherRedirectsDontForkProcess:BrowserTest.WindowOpenClose:ChromeAppAPITest.*:ChromeRenderProcessHostTest.*:ChromeRenderProcessHostTestWithCommandLine.*:DevToolsExperimentalExtensionTest.*:DevToolsExtensionTest.*:DnsProbeBrowserTest.*:ErrorPageTest.*:ExecuteScriptApiTest.ExecuteScriptPermissions:ExtensionApiTest.ActiveTab:ExtensionApiTest.ChromeRuntimeOpenOptionsPage:ExtensionApiTest.ContentScriptExtensionIframe:ExtensionApiTest.ContentScriptOtherExtensions:ExtensionApiTest.ContentScriptExtensionProcess:ExtensionApiTest.Tabs2:ExtensionApiTest.TabsOnUpdated:ExtensionApiTest.WindowOpenPopupIframe:ExtensionBrowserTest.LoadChromeExtensionsWithOptionsParamWhenEmbedded:ExtensionCrxInstallerTest.InstallDelayedUntilNextUpdate:ExtensionOptionsApiTest.ExtensionCanEmbedOwnOptions:ExtensionWebUITest.CanEmbedExtensionOptions:ExtensionWebUITest.ReceivesExtensionOptionsOnClose:InlineLoginUISafeIframeBrowserTest.*:IsolatedAppTest.*:LaunchWebAuthFlowFunctionTest.*:MimeHandlerViewTest.*:*.NewAvatarMenuEnabledInGuestMode:OptionsUIBrowserTest.*:*PDFExtensionTest.Load*:PhishingClassifierTest.*:PhishingDOMFeatureExtractorTest.*:PlatformAppUrlRedirectorBrowserTest.*:PopupBlockerBrowserTest.*:PrerenderBrowserTest.*:ProcessManagementTest.*:RedirectTest.*:ReferrerPolicyTest.*:SSLUITest.*:WebNavigationApiTest.CrossProcessFragment:WebNavigationApiTest.ServerRedirectSingleProcess:WebNavigationApiTest.CrossProcessHistory:WebViewDPITest.*:WebViewPluginTest.*:WebViewTest.*:ZoomControllerBrowserTest.*:*.NavigateFromNTPToOptionsInSameTab:*.ProfilesWithoutPagesNotLaunched:*.TabMove:*.WhitelistedExtension:*.NewTabPageURL:*.HomepageLocation:RestoreOnStartupPolicyTest*:PhishingClassifierDelegateTest.*:WebUIWebViewBrowserTest*" + "--gtest_filter=-AppApiTest.*:BlockedAppApiTest.*:BrowserTest.ClearPendingOnFailUnlessNTP:BrowserTest.OtherRedirectsDontForkProcess:BrowserTest.WindowOpenClose:ChromeAppAPITest.*:ChromeRenderProcessHostTest.*:ChromeRenderProcessHostTestWithCommandLine.*:DevToolsExperimentalExtensionTest.*:DevToolsExtensionTest.*:DnsProbeBrowserTest.*:ErrorPageTest.*:ExecuteScriptApiTest.ExecuteScriptPermissions:ExtensionApiTest.ActiveTab:ExtensionApiTest.ChromeRuntimeOpenOptionsPage:ExtensionApiTest.ContentScriptExtensionIframe:ExtensionApiTest.ContentScriptOtherExtensions:ExtensionApiTest.ContentScriptExtensionProcess:ExtensionApiTest.Tabs2:ExtensionApiTest.TabsOnUpdated:ExtensionApiTest.WindowOpenPopupIframe:ExtensionBrowserTest.LoadChromeExtensionsWithOptionsParamWhenEmbedded:ExtensionCrxInstallerTest.InstallDelayedUntilNextUpdate:ExtensionOptionsApiTest.ExtensionCanEmbedOwnOptions:ExtensionWebUITest.CanEmbedExtensionOptions:ExtensionWebUITest.ReceivesExtensionOptionsOnClose:InlineLoginUISafeIframeBrowserTest.*:IsolatedAppTest.*:LaunchWebAuthFlowFunctionTest.*:MimeHandlerViewTest.*:*.NewAvatarMenuEnabledInGuestMode:OptionsUIBrowserTest.*:*PDFExtensionTest.Load*:PhishingClassifierTest.*:PhishingDOMFeatureExtractorTest.*:PlatformAppUrlRedirectorBrowserTest.*:PopupBlockerBrowserTest.*:PrerenderBrowserTest.*:ProcessManagementTest.*:RedirectTest.*:ReferrerPolicyTest.*:SSLUITest.*:WebNavigationApiTest.CrossProcessFragment:WebNavigationApiTest.ServerRedirectSingleProcess:WebNavigationApiTest.CrossProcessHistory:WebViewCommonTest.*:WebViewDPITest.*:WebViewPluginTest.*:WebViewTest.*:ZoomControllerBrowserTest.*:*.NavigateFromNTPToOptionsInSameTab:*.ProfilesWithoutPagesNotLaunched:*.TabMove:*.WhitelistedExtension:*.NewTabPageURL:*.HomepageLocation:RestoreOnStartupPolicyTest*:PhishingClassifierDelegateTest.*:WebUIWebViewBrowserTest*" ], "test": "browser_tests" }, |