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

Unified Diff: chrome/test/data/extensions/api_test/content_scripts/policy/background.js

Issue 2833843004: Reland: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Removed unused URLPatternSet parameters in ExtensionMsg_PermissionSetStruct which was causing MSAN … Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/BUILD.gn ('k') | chrome/test/data/extensions/api_test/content_scripts/policy/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/content_scripts/policy/background.js
diff --git a/chrome/test/data/extensions/api_test/content_scripts/policy/background.js b/chrome/test/data/extensions/api_test/content_scripts/policy/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..7376923be897ad8ac4d4e62f4b6e76580e3973b7
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/content_scripts/policy/background.js
@@ -0,0 +1,53 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var pass = chrome.test.callbackPass;
+var callbackFail = chrome.test.callbackFail;
+var listenForever = chrome.test.listenForever;
+
+var port;
+
+function testUrl(domain) {
+ return 'http://' + domain + ':' + port +
+ '/extensions/test_file.html';
+}
+
+function error(domain) {
+ return 'Cannot access contents of url "' + testUrl(domain) + '".' +
+ ' Extension manifest must request permission to access this host.';
+}
+
+// Creates a new tab, navigated to the specified |domain|.
+function createTestTab(domain, callback) {
+ var createdTabId = -1;
+ var done = listenForever(
+ chrome.tabs.onUpdated,
+ function(tabId, changeInfo, tab) {
+ if (tabId == createdTabId && changeInfo.status != 'loading') {
+ callback(tab);
+ done();
+ }
+ });
+
+ chrome.tabs.create({url: testUrl(domain)}, pass(function(tab) {
+ createdTabId = tab.id;
+ }));
+}
+
+chrome.test.getConfig(function(config) {
+ port = config.testServer.port;
+ chrome.test.runTests([
+
+ // Make sure we can't inject a script into a policy blocked host.
+ function policyBlocksInjection() {
+ createTestTab('example.com', pass(function(tab) {
+ chrome.tabs.executeScript(
+ tab.id, {code: 'document.title = "success"'},
+ callbackFail(
+ 'This page cannot be scripted due to ' +
+ 'an ExtensionsSettings policy.'));
+ }));
+ },
+ ]);
+});
« no previous file with comments | « chrome/test/BUILD.gn ('k') | chrome/test/data/extensions/api_test/content_scripts/policy/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698