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

Side by Side Diff: chrome/test/data/extensions/api_test/executescript/basic/test.js

Issue 1628423002: Add frameId to chrome.tabs.executeScript/insertCSS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permissiondata-remove-process_id
Patch Set: Remove unused include from rebase Created 4 years, 10 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
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 var pass = chrome.test.callbackPass; 5 var pass = chrome.test.callbackPass;
6 var fail = chrome.test.callbackFail; 6 var fail = chrome.test.callbackFail;
7 var assertEq = chrome.test.assertEq; 7 var assertEq = chrome.test.assertEq;
8 var assertTrue = chrome.test.assertTrue; 8 var assertTrue = chrome.test.assertTrue;
9 var relativePath = 9 var relativePath =
10 '/extensions/api_test/executescript/basic/test_executescript.html'; 10 '/extensions/api_test/executescript/basic/test_executescript.html';
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 {code: 'document.title = document.styleSheets.length'}, 81 {code: 'document.title = document.styleSheets.length'},
82 function() { 82 function() {
83 chrome.tabs.get(tabId, pass(function(tab) { 83 chrome.tabs.get(tabId, pass(function(tab) {
84 assertEq('0', tab.title); 84 assertEq('0', tab.title);
85 })); 85 }));
86 }); 86 });
87 }); 87 });
88 }, 88 },
89 89
90 function executeJavaScriptCodeShouldFail() { 90 function executeJavaScriptCodeShouldFail() {
91 chrome.tabs.update(tabId, { url: testFailureUrl }, function() { 91 var doneListening =
92 chrome.test.listenForever(chrome.tabs.onUpdated, onUpdated);
93 chrome.tabs.update(tabId, {url: testFailureUrl});
94
95 function onUpdated(updatedTabId, changeInfo) {
96 if (updatedTabId !== tabId || changeInfo.url === testFailureUrl)
97 return;
92 var script_file = {}; 98 var script_file = {};
93 script_file.code = "document.title = 'executeScript';"; 99 script_file.code = "document.title = 'executeScript';";
94 // The error message should contain the URL of the site for which it 100 // The error message should contain the URL of the site for which it
95 // failed because the extension has the tabs permission. 101 // failed because the extension has the tabs permission.
96 chrome.tabs.executeScript(tabId, script_file, fail( 102 chrome.tabs.executeScript(tabId, script_file, fail(
97 'Cannot access contents of url "' + testFailureUrl + 103 'Cannot access contents of url "' + testFailureUrl +
98 '". Extension manifest must request permission to access this ' + 104 '". Extension manifest must request permission to access this ' +
99 'host.')); 105 'host.'));
100 }); 106 doneListening();
107 }
101 }, 108 },
102 109
103 function executeJavaScriptWithNoneValueShouldFail() { 110 function executeJavaScriptWithNoneValueShouldFail() {
104 var script_file = {}; 111 var script_file = {};
105 chrome.tabs.executeScript(tabId, script_file, fail( 112 chrome.tabs.executeScript(tabId, script_file, fail(
106 'No source code or file specified.')); 113 'No source code or file specified.'));
107 }, 114 },
108 115
109 function executeJavaScriptWithTwoValuesShouldFail() { 116 function executeJavaScriptWithTwoValuesShouldFail() {
110 var script_file = {}; 117 var script_file = {};
111 script_file.file = 'script1.js'; 118 script_file.file = 'script1.js';
112 script_file.code = 'var test = 1;'; 119 script_file.code = 'var test = 1;';
113 chrome.tabs.executeScript(tabId, script_file, fail( 120 chrome.tabs.executeScript(tabId, script_file, fail(
114 'Code and file should not be specified ' + 121 'Code and file should not be specified ' +
115 'at the same time in the second argument.')); 122 'at the same time in the second argument.'));
116 } 123 }
117 ]); 124 ]);
118 }); 125 });
119 126
120 chrome.tabs.create({ url: testUrl }); 127 chrome.tabs.create({ url: testUrl });
121 }); 128 });
122 129
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698