Index: chrome/browser/extensions/chrome_app_api_browsertest.cc |
diff --git a/chrome/browser/extensions/chrome_app_api_browsertest.cc b/chrome/browser/extensions/chrome_app_api_browsertest.cc |
index bef3c76f08990d7b0a65fbc0cdba710f4f72d96c..36c9ec8a0f0bfaa68153f99be3bd063551658164 100644 |
--- a/chrome/browser/extensions/chrome_app_api_browsertest.cc |
+++ b/chrome/browser/extensions/chrome_app_api_browsertest.cc |
@@ -27,41 +27,41 @@ using extensions::Extension; |
class ChromeAppAPITest : public ExtensionBrowserTest { |
protected: |
- bool IsAppInstalled() { return IsAppInstalled(L""); } |
- bool IsAppInstalled(const std::wstring& frame_xpath) { |
- std::wstring get_app_is_installed = |
- L"window.domAutomationController.send(window.chrome.app.isInstalled);"; |
+ bool IsAppInstalled() { return IsAppInstalled(""); } |
+ bool IsAppInstalled(const char* frame_xpath) { |
+ const char kGetAppIsInstalled[] = |
+ "window.domAutomationController.send(window.chrome.app.isInstalled);"; |
bool result; |
CHECK( |
content::ExecuteJavaScriptAndExtractBool( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- frame_xpath, get_app_is_installed, &result)); |
+ frame_xpath, kGetAppIsInstalled, &result)); |
return result; |
} |
- std::string InstallState() { return InstallState(L""); } |
- std::string InstallState(const std::wstring& frame_xpath) { |
- std::wstring get_app_install_state = |
- L"window.chrome.app.installState(" |
- L"function(s) { window.domAutomationController.send(s); });"; |
+ std::string InstallState() { return InstallState(""); } |
+ std::string InstallState(const char* frame_xpath) { |
+ const char kGetAppInstallState[] = |
+ "window.chrome.app.installState(" |
+ " function(s) { window.domAutomationController.send(s); });"; |
std::string result; |
CHECK( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- frame_xpath, get_app_install_state, &result)); |
+ frame_xpath, kGetAppInstallState, &result)); |
return result; |
} |
- std::string RunningState() { return RunningState(L""); } |
- std::string RunningState(const std::wstring& frame_xpath) { |
- std::wstring get_app_install_state = |
- L"window.domAutomationController.send(" |
- L"window.chrome.app.runningState());"; |
+ std::string RunningState() { return RunningState(""); } |
+ std::string RunningState(const char* frame_xpath) { |
+ const char kGetAppRunningState[] = |
+ "window.domAutomationController.send(" |
+ " window.chrome.app.runningState());"; |
std::string result; |
CHECK( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- frame_xpath, get_app_install_state, &result)); |
+ frame_xpath, kGetAppRunningState, &result)); |
return result; |
} |
@@ -108,14 +108,16 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, IsInstalled) { |
EXPECT_FALSE(IsAppInstalled()); |
// Test that a non-app page returns null for chrome.app.getDetails(). |
- std::wstring get_app_details = |
- L"window.domAutomationController.send(" |
- L" JSON.stringify(window.chrome.app.getDetails()));"; |
+ const char kGetAppDetails[] = |
+ "window.domAutomationController.send(" |
+ " JSON.stringify(window.chrome.app.getDetails()));"; |
std::string result; |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- L"", get_app_details, &result)); |
+ "", |
+ kGetAppDetails, |
+ &result)); |
EXPECT_EQ("null", result); |
// Check that an app page has chrome.app.isInstalled = true. |
@@ -128,7 +130,9 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, IsInstalled) { |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- L"", get_app_details, &result)); |
+ "", |
+ kGetAppDetails, |
+ &result)); |
scoped_ptr<DictionaryValue> app_details( |
static_cast<DictionaryValue*>(base::JSONReader::Read(result))); |
// extension->manifest() does not contain the id. |
@@ -141,19 +145,19 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, IsInstalled) { |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- L"", |
- L"window.domAutomationController.send(" |
- L" function() {" |
- L" var value = window.chrome.app.isInstalled;" |
- L" window.chrome.app.isInstalled = !value;" |
- L" if (window.chrome.app.isInstalled == value) {" |
- L" return 'true';" |
- L" } else {" |
- L" return 'false';" |
- L" }" |
- L" }()" |
- L");", |
- &result)); |
+ "", |
+ "window.domAutomationController.send(" |
+ " function() {" |
+ " var value = window.chrome.app.isInstalled;" |
+ " window.chrome.app.isInstalled = !value;" |
+ " if (window.chrome.app.isInstalled == value) {" |
+ " return 'true';" |
+ " } else {" |
+ " return 'false';" |
+ " }" |
+ " }()" |
+ ");", |
+ &result)); |
// Should not be able to alter window.chrome.app.isInstalled from javascript"; |
EXPECT_EQ("true", result); |
@@ -186,26 +190,30 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, GetDetailsForFrame) { |
// Test that normal pages (even apps) cannot use getDetailsForFrame(). |
ui_test_utils::NavigateToURL(browser(), app_url); |
- std::wstring test_unsuccessful_access = |
- L"window.domAutomationController.send(window.testUnsuccessfulAccess())"; |
+ const char kTestUnsuccessfulAccess[] = |
+ "window.domAutomationController.send(window.testUnsuccessfulAccess())"; |
bool result = false; |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractBool( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- L"", test_unsuccessful_access, &result)); |
+ "", |
+ kTestUnsuccessfulAccess, |
+ &result)); |
EXPECT_TRUE(result); |
// Test that checkout can use getDetailsForFrame() and that it works |
// correctly. |
ui_test_utils::NavigateToURL(browser(), checkout_url); |
- std::wstring get_details_for_frame = |
- L"window.domAutomationController.send(" |
- L" JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))"; |
+ const char kGetDetailsForFrame[] = |
+ "window.domAutomationController.send(" |
+ " JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))"; |
std::string json; |
ASSERT_TRUE( |
content::ExecuteJavaScriptAndExtractString( |
chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
- L"", get_details_for_frame, &json)); |
+ "", |
+ kGetDetailsForFrame, |
+ &json)); |
scoped_ptr<DictionaryValue> app_details( |
static_cast<DictionaryValue*>(base::JSONReader::Read(json))); |
@@ -276,9 +284,9 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, InstallAndRunningState) { |
EXPECT_EQ("cannot_run", RunningState()); |
EXPECT_FALSE(IsAppInstalled()); |
- EXPECT_EQ("installed", InstallState(L"//html/iframe[1]")); |
- EXPECT_EQ("cannot_run", RunningState(L"//html/iframe[1]")); |
- EXPECT_FALSE(IsAppInstalled(L"//html/iframe[1]")); |
+ EXPECT_EQ("installed", InstallState("//html/iframe[1]")); |
+ EXPECT_EQ("cannot_run", RunningState("//html/iframe[1]")); |
+ EXPECT_FALSE(IsAppInstalled("//html/iframe[1]")); |
} |
@@ -304,7 +312,7 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, InstallAndRunningStateFrame) { |
// within an app. |
ui_test_utils::NavigateToURL(browser(), app_url); |
- EXPECT_EQ("not_installed", InstallState(L"//html/iframe[1]")); |
- EXPECT_EQ("cannot_run", RunningState(L"//html/iframe[1]")); |
- EXPECT_FALSE(IsAppInstalled(L"//html/iframe[1]")); |
+ EXPECT_EQ("not_installed", InstallState("//html/iframe[1]")); |
+ EXPECT_EQ("cannot_run", RunningState("//html/iframe[1]")); |
+ EXPECT_FALSE(IsAppInstalled("//html/iframe[1]")); |
} |