Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/extensions/chrome_app_api_browsertest.cc

Issue 8786004: Revert "Restrict extension features based on the extension type." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/extension_browsertest.h" 12 #include "chrome/browser/extensions/extension_browsertest.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/manifest.h"
17 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
19 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
20 #include "net/base/mock_host_resolver.h" 19 #include "net/base/mock_host_resolver.h"
21 20
22 class ChromeAppAPITest : public ExtensionBrowserTest { 21 class ChromeAppAPITest : public ExtensionBrowserTest {
23 protected: 22 protected:
24 bool IsAppInstalled() { 23 bool IsAppInstalled() {
25 std::wstring get_app_is_installed = 24 std::wstring get_app_is_installed =
26 L"window.domAutomationController.send(window.chrome.app.isInstalled);"; 25 L"window.domAutomationController.send(window.chrome.app.isInstalled);";
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Check that an app page returns the correct result for 91 // Check that an app page returns the correct result for
93 // chrome.app.getDetails(). 92 // chrome.app.getDetails().
94 ui_test_utils::NavigateToURL(browser(), app_url); 93 ui_test_utils::NavigateToURL(browser(), app_url);
95 ASSERT_TRUE( 94 ASSERT_TRUE(
96 ui_test_utils::ExecuteJavaScriptAndExtractString( 95 ui_test_utils::ExecuteJavaScriptAndExtractString(
97 browser()->GetSelectedTabContents()->render_view_host(), 96 browser()->GetSelectedTabContents()->render_view_host(),
98 L"", get_app_details, &result)); 97 L"", get_app_details, &result));
99 scoped_ptr<DictionaryValue> app_details( 98 scoped_ptr<DictionaryValue> app_details(
100 static_cast<DictionaryValue*>( 99 static_cast<DictionaryValue*>(
101 base::JSONReader::Read(result, false /* allow trailing comma */))); 100 base::JSONReader::Read(result, false /* allow trailing comma */)));
102 // extension->manifest() does not contain the id. 101 // extension->manifest_value() does not contain the id.
103 app_details->Remove("id", NULL); 102 app_details->Remove("id", NULL);
104 EXPECT_TRUE(app_details.get()); 103 EXPECT_TRUE(app_details.get());
105 EXPECT_TRUE(app_details->Equals(extension->manifest()->value())); 104 EXPECT_TRUE(app_details->Equals(extension->manifest_value()));
106 105
107 // Try to change app.isInstalled. Should silently fail, so 106 // Try to change app.isInstalled. Should silently fail, so
108 // that isInstalled should have the initial value. 107 // that isInstalled should have the initial value.
109 ASSERT_TRUE( 108 ASSERT_TRUE(
110 ui_test_utils::ExecuteJavaScriptAndExtractString( 109 ui_test_utils::ExecuteJavaScriptAndExtractString(
111 browser()->GetSelectedTabContents()->render_view_host(), 110 browser()->GetSelectedTabContents()->render_view_host(),
112 L"", 111 L"",
113 L"window.domAutomationController.send(" 112 L"window.domAutomationController.send("
114 L" function() {" 113 L" function() {"
115 L" var value = window.chrome.app.isInstalled;" 114 L" var value = window.chrome.app.isInstalled;"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 L" JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))"; 170 L" JSON.stringify(chrome.app.getDetailsForFrame(frames[0])))";
172 std::string json; 171 std::string json;
173 ASSERT_TRUE( 172 ASSERT_TRUE(
174 ui_test_utils::ExecuteJavaScriptAndExtractString( 173 ui_test_utils::ExecuteJavaScriptAndExtractString(
175 browser()->GetSelectedTabContents()->render_view_host(), 174 browser()->GetSelectedTabContents()->render_view_host(),
176 L"", get_details_for_frame, &json)); 175 L"", get_details_for_frame, &json));
177 176
178 scoped_ptr<DictionaryValue> app_details( 177 scoped_ptr<DictionaryValue> app_details(
179 static_cast<DictionaryValue*>( 178 static_cast<DictionaryValue*>(
180 base::JSONReader::Read(json, false /* allow trailing comma */))); 179 base::JSONReader::Read(json, false /* allow trailing comma */)));
181 // extension->manifest() does not contain the id. 180 // extension->manifest_value() does not contain the id.
182 app_details->Remove("id", NULL); 181 app_details->Remove("id", NULL);
183 EXPECT_TRUE(app_details.get()); 182 EXPECT_TRUE(app_details.get());
184 EXPECT_TRUE(app_details->Equals(extension->manifest()->value())); 183 EXPECT_TRUE(app_details->Equals(extension->manifest_value()));
185 } 184 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698