| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 = '/extensions/api_test/executescript/frame_id/frames.html'; | 9 var relativePath = '/extensions/api_test/executescript/frame_id/frames.html'; |
| 10 var testOrigin = 'http://a.com:PORT'; | 10 var testOrigin = 'http://a.com:PORT'; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 }, | 237 }, |
| 238 | 238 |
| 239 function executeScriptWithNegativeFrameId() { | 239 function executeScriptWithNegativeFrameId() { |
| 240 try { | 240 try { |
| 241 chrome.tabs.executeScript( | 241 chrome.tabs.executeScript( |
| 242 tabId, {frameId: -1, code: 'document.URL'}, function() { | 242 tabId, {frameId: -1, code: 'document.URL'}, function() { |
| 243 chrome.test.fail( | 243 chrome.test.fail( |
| 244 'executeScript should never have been executed!'); | 244 'executeScript should never have been executed!'); |
| 245 }); | 245 }); |
| 246 } catch (e) { | 246 } catch (e) { |
| 247 assertEq( | 247 assertTrue( |
| 248 'Invalid value for argument 2. Property \'frameId\': ' + | 248 // JS-based bindings. |
| 249 'Value must not be less than 0.', | 249 e.message == 'Invalid value for argument 2. Property \'frameId\':' + |
| 250 ' Value must not be less than 0.' || |
| 251 // Native bindings. |
| 252 e.message == 'Error in invocation of tabs.executeScript(' + |
| 253 'optional integer tabId, ' + |
| 254 'extensionTypes.InjectDetails details, ' + |
| 255 'optional function callback): Error at parameter ' + |
| 256 '\'details\': Error at property \'frameId\': ' + |
| 257 'Value must be at least 0.', |
| 250 e.message); | 258 e.message); |
| 251 chrome.test.succeed(); | 259 chrome.test.succeed(); |
| 252 } | 260 } |
| 253 }, | 261 }, |
| 254 | 262 |
| 255 function insertCSSInTopFrame() { | 263 function insertCSSInTopFrame() { |
| 256 insertCSS(tabId, {frameId: 0}, pass(function(results) { | 264 insertCSS(tabId, {frameId: 0}, pass(function(results) { |
| 257 assertEq(1, results.length); | 265 assertEq(1, results.length); |
| 258 assertTrue(matchesAny(results, R_FRAME_TOP)); | 266 assertTrue(matchesAny(results, R_FRAME_TOP)); |
| 259 })); | 267 })); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 fail('No frame with id 999999999 in tab ' + tabId + '.')); | 368 fail('No frame with id 999999999 in tab ' + tabId + '.')); |
| 361 }, | 369 }, |
| 362 | 370 |
| 363 function insertCSSWithNegativeFrameId() { | 371 function insertCSSWithNegativeFrameId() { |
| 364 try { | 372 try { |
| 365 chrome.tabs.insertCSS( | 373 chrome.tabs.insertCSS( |
| 366 tabId, {frameId: -1, code: 'body{color:red}'}, function() { | 374 tabId, {frameId: -1, code: 'body{color:red}'}, function() { |
| 367 chrome.test.fail('insertCSS should never have been executed!'); | 375 chrome.test.fail('insertCSS should never have been executed!'); |
| 368 }); | 376 }); |
| 369 } catch (e) { | 377 } catch (e) { |
| 370 assertEq( | 378 assertTrue( |
| 371 'Invalid value for argument 2. Property \'frameId\': ' + | 379 // JS-based bindings. |
| 372 'Value must not be less than 0.', | 380 e.message == 'Invalid value for argument 2. Property \'frameId\':' + |
| 381 ' Value must not be less than 0.' || |
| 382 // Native bindings. |
| 383 e.message == 'Error in invocation of tabs.insertCSS(' + |
| 384 'optional integer tabId, ' + |
| 385 'extensionTypes.InjectDetails details, ' + |
| 386 'optional function callback): Error at parameter ' + |
| 387 '\'details\': Error at property \'frameId\': ' + |
| 388 'Value must be at least 0.', |
| 373 e.message); | 389 e.message); |
| 374 chrome.test.succeed(); | 390 chrome.test.succeed(); |
| 375 } | 391 } |
| 376 }, | 392 }, |
| 377 | 393 |
| 378 ]); | 394 ]); |
| 379 } | 395 } |
| OLD | NEW |