OLD | NEW |
---|---|
(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); | |
karandeepb
2017/07/18 19:27:00
I am not up to speed with how different JS types b
Devlin
2017/07/18 20:53:46
!!x checks that x is not "false-y". This has trad
karandeepb
2017/07/18 21:06:25
Acknowledged.
| |
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 }); | |
OLD | NEW |