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

Side by Side Diff: chrome/test/data/extensions/api_test/permissions/optional_retain_gesture/background.js

Issue 2360073002: [Extensions] Isolate ExtensionFunction results_ and error_ (Closed)
Patch Set: errorwithargs Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 fail = chrome.test.callbackFail; 5 var fail = chrome.test.callbackFail;
6 6
7 var GESTURE_ERROR = "This function must be called during a user gesture"; 7 var GESTURE_ERROR = "This function must be called during a user gesture";
8 8
9 function busyLoop(milliseconds) { 9 function busyLoop(milliseconds) {
10 var startTime = new Date().getTime(); 10 var startTime = new Date().getTime();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 function(granted) { 48 function(granted) {
49 chrome.test.assertTrue(granted); 49 chrome.test.assertTrue(granted);
50 50
51 var request = function() { 51 var request = function() {
52 // The following request will fail if the user gesture is 52 // The following request will fail if the user gesture is
53 // expired. 53 // expired.
54 chrome.permissions.request( 54 chrome.permissions.request(
55 {permissions: ['bookmarks']}, 55 {permissions: ['bookmarks']},
56 function(granted1) { 56 function(granted1) {
57 if (chrome.runtime.lastError) { 57 if (chrome.runtime.lastError) {
58 chrome.test.assertFalse(granted1); 58 chrome.test.assertFalse(!!granted1);
59 chrome.test.assertEq(chrome.runtime.lastError.message, 59 chrome.test.assertEq(chrome.runtime.lastError.message,
60 GESTURE_ERROR); 60 GESTURE_ERROR);
61 chrome.test.succeed(); 61 chrome.test.succeed();
62 } else { 62 } else {
63 console.log("Retrying permissions.request in 3 " + 63 console.log("Retrying permissions.request in 3 " +
64 "seconds"); 64 "seconds");
65 busyLoop(3000); 65 busyLoop(3000);
66 request(); 66 request();
67 } 67 }
68 }); 68 });
69 }; 69 };
70 70
71 // Wait 2s since the user gesture timeout is 1s. 71 // Wait 2s since the user gesture timeout is 1s.
72 busyLoop(2000); 72 busyLoop(2000);
73 request(); 73 request();
74 } 74 }
75 ); 75 );
76 }); 76 });
77 } 77 }
78 ]); 78 ]);
79 }); 79 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698