summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/apps/guest_view/web_view_browsertest.cc4
-rw-r--r--chrome/test/data/extensions/platform_apps/web_view/shim/main.js24
-rw-r--r--content/renderer/browser_plugin/browser_plugin.cc24
-rw-r--r--content/renderer/browser_plugin/browser_plugin.h2
4 files changed, 46 insertions, 8 deletions
diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc
index c38fa51..f2a225c 100644
--- a/chrome/browser/apps/guest_view/web_view_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc
@@ -959,6 +959,10 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestDisplayNoneWebviewRemoveChild) {
"web_view/shim", NO_TEST_SERVER);
}
+IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestDisplayBlock) {
+ TestHelper("testDisplayBlock", "web_view/shim", NO_TEST_SERVER);
+}
+
IN_PROC_BROWSER_TEST_F(WebViewTest,
Shim_TestInlineScriptFromAccessibleResources) {
TestHelper("testInlineScriptFromAccessibleResources",
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
index 624ff5c..31d1c37 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
@@ -1238,6 +1238,29 @@ function testDeclarativeWebRequestAPISendMessage() {
document.body.appendChild(webview);
}
+// This test verifies that setting a <webview>'s style.display = 'block' does
+// not throw and attach error.
+function testDisplayBlock() {
+ var webview = new WebView();
+ webview.onloadstop = function(e) {
+ LOG('webview.onloadstop');
+ window.console.error = function() {
+ // If we see an error, that means attach failed.
+ embedder.test.fail();
+ };
+ webview.style.display = 'block';
+ embedder.test.assertTrue(webview.getProcessId() > 0);
+
+ webview.onloadstop = function(e) {
+ LOG('Second webview.onloadstop');
+ embedder.test.succeed();
+ };
+ webview.src = 'data:text/html,<body>Second load</body>';
+ }
+ webview.src = 'about:blank';
+ document.body.appendChild(webview);
+}
+
// This test verifies that the WebRequest API onBeforeRequest event fires on
// clients*.google.com URLs.
function testWebRequestAPIGoogleProperty() {
@@ -2127,6 +2150,7 @@ embedder.test.testList = {
'testDeclarativeWebRequestAPI': testDeclarativeWebRequestAPI,
'testDeclarativeWebRequestAPISendMessage':
testDeclarativeWebRequestAPISendMessage,
+ 'testDisplayBlock': testDisplayBlock,
'testWebRequestAPI': testWebRequestAPI,
'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders,
'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty,
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 0784222..38d4bff 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -300,14 +300,12 @@ bool BrowserPlugin::initialize(WebPluginContainer* container) {
BrowserPluginManager::Get()->AddBrowserPlugin(
browser_plugin_instance_id_, this);
- // This is a way to notify observers of our attributes that this plugin is
- // available in render tree.
- // TODO(lazyboy): This should be done through the delegate instead. Perhaps
- // by firing an event from there.
- UpdateDOMAttribute(
- "internalinstanceid",
- base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_)));
-
+ // Defer attach call so that if there's any pending browser plugin
+ // destruction, then it can progress first.
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&BrowserPlugin::UpdateInternalInstanceId,
+ weak_ptr_factory_.GetWeakPtr()));
return true;
}
@@ -333,6 +331,16 @@ void BrowserPlugin::EnableCompositing(bool enable) {
}
}
+void BrowserPlugin::UpdateInternalInstanceId() {
+ // This is a way to notify observers of our attributes that this plugin is
+ // available in render tree.
+ // TODO(lazyboy): This should be done through the delegate instead. Perhaps
+ // by firing an event from there.
+ UpdateDOMAttribute(
+ "internalinstanceid",
+ base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_)));
+}
+
void BrowserPlugin::destroy() {
if (container_) {
// The BrowserPlugin's WebPluginContainer is deleted immediately after this
diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h
index d2b65cd..37ee47a 100644
--- a/content/renderer/browser_plugin/browser_plugin.h
+++ b/content/renderer/browser_plugin/browser_plugin.h
@@ -55,6 +55,8 @@ class CONTENT_EXPORT BrowserPlugin :
// A request to enable hardware compositing.
void EnableCompositing(bool enable);
+ void UpdateInternalInstanceId();
+
// Provided that a guest instance ID has been allocated, this method attaches
// this BrowserPlugin instance to that guest.
void Attach();