summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 20:14:53 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 20:14:53 +0000
commitab9b01926d01eac4a9b23c5667ac502da7c58b58 (patch)
treef43ca318db9a3fc6d13421fa560b3096d30b4737 /chrome
parent4940216a4f034e8de5740d30b413eec3ed495b6d (diff)
downloadchromium_src-ab9b01926d01eac4a9b23c5667ac502da7c58b58.zip
chromium_src-ab9b01926d01eac4a9b23c5667ac502da7c58b58.tar.gz
chromium_src-ab9b01926d01eac4a9b23c5667ac502da7c58b58.tar.bz2
Reenable use of ExecuteScriptInNewWorld.
I didn't even realize I checked in the code that disabled it. BUG=no TEST=no Review URL: http://codereview.chromium.org/159454 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_browsertests_misc.cc26
-rw-r--r--chrome/renderer/user_script_slave.cc5
-rw-r--r--chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js9
-rw-r--r--chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html19
4 files changed, 40 insertions, 19 deletions
diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc
index 9c9a50d..6966f54 100644
--- a/chrome/browser/extensions/extension_browsertests_misc.cc
+++ b/chrome/browser/extensions/extension_browsertests_misc.cc
@@ -296,24 +296,25 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MessagingExtensionTab) {
browser(),
GURL("chrome-extension://bjafgdebaacbbbecmhlhpofkepfkgcpa/page.html"));
- // First test that tab->extension messaging works.
+ // Test extension->tab messaging.
bool result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
- browser()->GetSelectedTabContents()->render_view_host(), L"",
- L"testPostMessageFromTab()", &result);
+ host->render_view_host(), L"", L"testPostMessage()", &result);
EXPECT_TRUE(result);
- // Now test extension->tab messaging, with disconnect events.
+ // Test tab->extension messaging.
result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testDisconnect()", &result);
+ host->render_view_host(), L"", L"testPostMessageFromTab()", &result);
EXPECT_TRUE(result);
+ // Test disconnect event dispatch.
result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testPostMessage()", &result);
+ host->render_view_host(), L"", L"testDisconnect()", &result);
EXPECT_TRUE(result);
+ // Test disconnect is fired on tab close.
result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
host->render_view_host(), L"", L"testDisconnectOnClose()", &result);
@@ -349,24 +350,25 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MessagingContentScript) {
.AppendASCII("test_file.html");
ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file));
- // First test that tab->extension messaging works.
+ // Test extension->tab messaging.
bool result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
- browser()->GetSelectedTabContents()->render_view_host(), L"",
- L"testPostMessageFromTab()", &result);
+ host->render_view_host(), L"", L"testPostMessage()", &result);
EXPECT_TRUE(result);
- // Now test extension->tab messaging, with disconnect events.
+ // Test tab->extension messaging.
result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testDisconnect()", &result);
+ host->render_view_host(), L"", L"testPostMessageFromTab()", &result);
EXPECT_TRUE(result);
+ // Test disconnect event dispatch.
result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testPostMessage()", &result);
+ host->render_view_host(), L"", L"testDisconnect()", &result);
EXPECT_TRUE(result);
+ // Test disconnect is fired on tab close.
result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
host->render_view_host(), L"", L"testDisconnectOnClose()", &result);
diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc
index 088f409..48017c1 100644
--- a/chrome/renderer/user_script_slave.cc
+++ b/chrome/renderer/user_script_slave.cc
@@ -160,10 +160,7 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame,
StringPrintf(kInitExtension, script->extension_id().c_str()))));
}
- // TODO(abarth): switch back to NewWorld when V8IsolatedWorld is fixed.
- // https://bugs.webkit.org/show_bug.cgi?id=27397
- frame->ExecuteScriptInNewContext(&sources.front(), sources.size());
- // frame->ExecuteScriptInNewWorld(&sources.front(), sources.size());
+ frame->ExecuteScriptInNewWorld(&sources.front(), sources.size());
}
}
diff --git a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js
index cee9476..feacd93 100644
--- a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js
+++ b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js
@@ -12,6 +12,8 @@ win.onload = function() {
console.log('got ' + msg);
if (msg.testPostMessage) {
port.postMessage({success: true});
+ } else if (msg.testPostMessageFromTab) {
+ testPostMessageFromTab(port);
} else if (msg.testDisconnect) {
port.disconnect();
} else if (msg.testDisconnectOnClose) {
@@ -20,14 +22,15 @@ win.onload = function() {
// Ignore other messages since they are from us.
});
});
-}
+};
// Tests that postMessage to the extension and its response works.
-win.testPostMessageFromTab = function() {
+function testPostMessageFromTab(origPort) {
+ console.log('testPostMessageFromTab');
var port = chrome.extension.connect();
port.postMessage({testPostMessageFromTab: true});
port.onMessage.addListener(function(msg) {
- win.domAutomationController.send(msg.success);
+ origPort.postMessage({success: msg.success});
console.log('sent ' + msg.success);
port.disconnect();
});
diff --git a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html
index aae7daa..a8bfe7e 100644
--- a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html
+++ b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html
@@ -1,9 +1,12 @@
<script>
window.onload = function() {
chrome.extension.onConnect.addListener(function(port) {
+ console.log('onConnect');
port.onMessage.addListener(function(msg) {
+ console.log('got message');
if (msg.testPostMessageFromTab) {
port.postMessage({success: true});
+ console.log('sent success');
}
// Ignore other messages since they are from us.
});
@@ -14,6 +17,7 @@ window.onload = function() {
function testPostMessage() {
chrome.tabs.getSelected(null, function(tab) {
var port = chrome.tabs.connect(tab.id);
+ console.log('connect to ' + tab.id);
port.postMessage({testPostMessage: true});
port.onMessage.addListener(function(msg) {
window.domAutomationController.send(msg.success);
@@ -22,10 +26,24 @@ function testPostMessage() {
});
}
+// Tests that postMessage from the tab and its response works.
+function testPostMessageFromTab() {
+ chrome.tabs.getSelected(null, function(tab) {
+ var port = chrome.tabs.connect(tab.id);
+ console.log('connect to ' + tab.id);
+ port.postMessage({testPostMessageFromTab: true});
+ port.onMessage.addListener(function(msg) {
+ window.domAutomationController.send(msg.success);
+ port.disconnect();
+ });
+ });
+}
+
// Tests that we get the disconnect event when the tab disconnect.
function testDisconnect() {
chrome.tabs.getSelected(null, function(tab) {
var port = chrome.tabs.connect(tab.id);
+ console.log('connect to ' + tab.id);
port.postMessage({testDisconnect: true});
port.onDisconnect.addListener(function() {
window.domAutomationController.send(true);
@@ -37,6 +55,7 @@ function testDisconnect() {
function testDisconnectOnClose() {
chrome.tabs.getSelected(null, function(tab) {
var port = chrome.tabs.connect(tab.id);
+ console.log('connect to ' + tab.id);
port.postMessage({testDisconnectOnClose: true});
port.onDisconnect.addListener(function() {
window.domAutomationController.send(true);