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

Side by Side Diff: chrome/test/data/extensions/api_test/permissions/optional_deny/background.html

Issue 8757010: Move another block of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 <script> 1 <!--
2 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 var assertFalse = chrome.test.assertFalse; 3 * source code is governed by a BSD-style license that can be found in the
4 var assertTrue = chrome.test.assertTrue; 4 * LICENSE file.
5 var pass = chrome.test.callbackPass; 5 -->
6 6 <script src="background.js"></script>
7 var NO_TABS_PERMISSION =
8 "You do not have permission to use 'windows.getAll'.";
9
10 chrome.test.getConfig(function(config) {
11
12 function doReq(domain, callback) {
13 var req = new XMLHttpRequest();
14 var url = domain + ":PORT/files/extensions/test_file.txt";
15 url = url.replace(/PORT/, config.testServer.port);
16
17 chrome.test.log("Requesting url: " + url);
18 req.open("GET", url, true);
19
20 req.onload = function() {
21 assertEq(200, req.status);
22 assertEq("Hello!", req.responseText);
23 callback(true);
24 };
25
26 req.onerror = function() {
27 chrome.test.log("status: " + req.status);
28 chrome.test.log("text: " + req.responseText);
29 callback(false);
30 };
31
32 req.send(null);
33 }
34
35 chrome.test.runTests([
36 function denyRequest() {
37 chrome.permissions.request(
38 {permissions: ['tabs'], origins: ['http://*.c.com/*']},
39 pass(function(granted) {
40 // They were not granted, and there should be no error.
41 assertFalse(granted);
42 assertTrue(chrome.extension.lastError === undefined);
43
44 // Make sure they weren't granted...
45 chrome.permissions.contains(
46 {permissions: ['tabs'], origins:['http://*.c.com/*']},
47 pass(function(result) { assertFalse(result); }));
48
49 try {
50 chrome.windows.getAll({populate: true}, function() {
51 chrome.test.fail("Should not have tabs API permission.");
52 });
53 } catch (e) {
54 assertTrue(e.message.indexOf(NO_TABS_PERMISSION) == 0);
55 }
56
57 doReq('http://b.c.com/', pass(function(result) {
58 assertFalse(result);
59 }));
60 }));
61 }
62 ]);
63 });
64 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698