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

Side by Side Diff: chrome/test/data/extensions/api_test/content_scripts/ntp/background.js

Issue 2978953002: [Extensions] Don't allow content scripts on the New Tab Page (Closed)
Patch Set: Remove logging! Created 3 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function testExecuteScriptInNewTab() {
6 // Create a new tab to chrome://newtab and wait for the loading to complete.
7 // Then, try to inject a script into that tab. The injection should fail.
8 chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo, tab) {
9 if (tab.url != 'chrome://newtab/' || changeInfo.status != 'complete')
10 return;
11 chrome.tabs.onUpdated.removeListener(listener);
12 chrome.tabs.executeScript(tab.id, {file: 'script.js'}, function() {
13 chrome.test.assertTrue(!!chrome.runtime.lastError);
14 chrome.test.assertTrue(
15 chrome.runtime.lastError.message.indexOf(
16 'Cannot access contents of') != -1,
17 chrome.runtime.lastError.message);
18 chrome.test.succeed();
19 });
20 });
21 chrome.tabs.create({url: 'chrome://newtab'});
22 }
23
24 chrome.test.sendMessage('ready', function() {
25 chrome.test.runTests([testExecuteScriptInNewTab]);
26 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698