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

Side by Side Diff: chrome/test/data/extensions/api_test/webstore_inline_install/download_progress_listener.html

Issue 175263003: Add chrome.webstore API methods to allow sites to see progress of installation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 6 years, 9 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <link rel="chrome-webstore-item"> 4 <link rel="chrome-webstore-item">
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 console.log('Page loaded');
9
10 function runTest(galleryUrl) { 8 function runTest(galleryUrl) {
11 console.log('In runTest'); 9 var receivedProgressUpdate = false;
12 10
13 // Link URL has to be generated dynamically in order to include the right 11 // Link URL has to be generated dynamically in order to include the right
14 // port number. The ID corresponds to the data in the "extension" directory. 12 // port number. The ID corresponds to the data in the "extension" directory.
15 document.getElementsByTagName('link')[0].href = 13 document.getElementsByTagName('link')[0].href =
16 galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje'; 14 galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje';
17 15
18 try { 16 try {
17 chrome.webstore.onDownloadProgress.addListener(function(progress) {
18 if (progress < 0 || progress > 1.0) {
19 console.log('Received invalid download progress: ' + progress);
20 window.domAutomationController.send(false);
21 }
22 receivedProgressUpdate = true;
23 });
19 chrome.webstore.install( 24 chrome.webstore.install(
20 undefined, 25 undefined,
21 function() { 26 function() {
22 console.log('Ran test, sending response'); 27 if (!receivedProgressUpdate) {
28 console.log(
29 'Test Failed: Did not receive download progress update.');
30 window.domAutomationController.send(false);
31 }
23 window.domAutomationController.send(true); 32 window.domAutomationController.send(true);
24 console.log('Test complete');
25 }, 33 },
26 function(error) { 34 function(error) {
27 console.log('Unexpected error: ' + error); 35 console.log('Unexpected error: ' + error);
28 window.domAutomationController.send(false); 36 window.domAutomationController.send(false);
29 }); 37 });
30 // Force a garbage collection, so that if the callbacks aren't being 38 // Force a garbage collection, so that if the callbacks aren't being
31 // retained properly they'll get collected and the test will fail. 39 // retained properly they'll get collected and the test will fail.
32 window.gc(); 40 window.gc();
33 } catch (e) { 41 } catch (e) {
34 console.log('Unexpected exception: ' + e); 42 console.log('Unexpected exception: ' + e);
43 console.log(e.stack);
35 window.domAutomationController.send(false); 44 window.domAutomationController.send(false);
36 throw e; 45 throw e;
37 } 46 }
38 } 47 }
39 </script> 48 </script>
40 49
41 </body> 50 </body>
42 </html> 51 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698