| 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 // The empty app doesn't add any context menu items, so its menu should | 129 // The empty app doesn't add any context menu items, so its menu should |
| 130 // only include the developer tools. | 130 // only include the developer tools. |
| 131 WebContents* web_contents = GetFirstPlatformAppWebContents(); | 131 WebContents* web_contents = GetFirstPlatformAppWebContents(); |
| 132 ASSERT_TRUE(web_contents); | 132 ASSERT_TRUE(web_contents); |
| 133 WebKit::WebContextMenuData data; | 133 WebKit::WebContextMenuData data; |
| 134 content::ContextMenuParams params(data); | 134 content::ContextMenuParams params(data); |
| 135 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, | 135 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, |
| 136 params); | 136 params); |
| 137 menu->Init(); | 137 menu->Init(); |
| 138 ASSERT_EQ(1, menu->menu_model().GetItemCount()); | 138 // 3 including separator |
| 139 ASSERT_EQ(3, menu->menu_model().GetItemCount()); |
| 139 } | 140 } |
| 140 | 141 |
| 141 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) { | 142 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) { |
| 142 ExtensionTestMessageListener listener1("created item", false); | 143 ExtensionTestMessageListener listener1("created item", false); |
| 143 LoadAndLaunchPlatformApp("context_menu"); | 144 LoadAndLaunchPlatformApp("context_menu"); |
| 144 | 145 |
| 145 // Wait for the extension to tell us it's created an item. | 146 // Wait for the extension to tell us it's created an item. |
| 146 ASSERT_TRUE(listener1.WaitUntilSatisfied()); | 147 ASSERT_TRUE(listener1.WaitUntilSatisfied()); |
| 147 | 148 |
| 148 // The context_menu app has one context menu item. This, along with a | 149 // The context_menu app has one context menu item. This, along with a |
| 149 // separator and the developer tools, is all that should be in the menu. | 150 // separator and the developer tools, is all that should be in the menu. |
| 150 WebContents* web_contents = GetFirstPlatformAppWebContents(); | 151 WebContents* web_contents = GetFirstPlatformAppWebContents(); |
| 151 ASSERT_TRUE(web_contents); | 152 ASSERT_TRUE(web_contents); |
| 152 WebKit::WebContextMenuData data; | 153 WebKit::WebContextMenuData data; |
| 153 content::ContextMenuParams params(data); | 154 content::ContextMenuParams params(data); |
| 154 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, | 155 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, |
| 155 params); | 156 params); |
| 156 menu->Init(); | 157 menu->Init(); |
| 157 ASSERT_EQ(3, menu->menu_model().GetItemCount()); | 158 ASSERT_EQ(4, menu->menu_model().GetItemCount()); |
| 158 } | 159 } |
| 159 | 160 |
| 160 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { | 161 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { |
| 161 ASSERT_TRUE(test_server()->Start()); | 162 ASSERT_TRUE(test_server()->Start()); |
| 162 | 163 |
| 163 LoadAndLaunchPlatformApp("navigation"); | 164 LoadAndLaunchPlatformApp("navigation"); |
| 164 WebContents* web_contents = GetFirstPlatformAppWebContents(); | 165 WebContents* web_contents = GetFirstPlatformAppWebContents(); |
| 165 | 166 |
| 166 GURL remote_url = test_server()->GetURL( | 167 GURL remote_url = test_server()->GetURL( |
| 167 "files/extensions/platform_apps/navigation/nav-target.html"); | 168 "files/extensions/platform_apps/navigation/nav-target.html"); |
| 168 | 169 |
| 169 std::string script = StringPrintf( | 170 std::string script = StringPrintf( |
| 170 "runTests(\"%s\")", remote_url.spec().c_str()); | 171 "runTests(\"%s\")", remote_url.spec().c_str()); |
| 171 bool result = false; | 172 bool result = false; |
| 172 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 173 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 173 web_contents->GetRenderViewHost(), L"", | 174 web_contents->GetRenderViewHost(), L"", |
| 174 UTF8ToWide(script), &result)); | 175 UTF8ToWide(script), &result)); |
| 175 EXPECT_TRUE(result); | 176 EXPECT_TRUE(result); |
| 176 } | 177 } |
| 177 | 178 |
| 178 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowModalDialogs) { | 179 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowModalDialogs) { |
| 179 ASSERT_TRUE(RunPlatformAppTest("platform_apps/modal_dialogs")) << message_; | 180 ASSERT_TRUE(RunPlatformAppTest("platform_apps/modal_dialogs")) << message_; |
| 180 } | 181 } |
| 181 | 182 |
| 182 // Tests that localStorage and WebSQL are disabled for platform apps. | 183 // Tests that localStorage and WebSQL are disabled for platform apps. |
| 183 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) { | 184 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) { |
| 184 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_; | 185 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_; |
| 185 } | 186 } |
| OLD | NEW |