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

Side by Side Diff: chrome/test/data/extensions/api_test/webstore_inline_install/install_stage_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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="chrome-webstore-item">
5 </head>
6 <body>
7 <script>
8 function runTest(galleryUrl) {
9 var downloadStarted = false;
10 var installStarted = false;
11
12 // Link URL has to be generated dynamically in order to include the right
13 // port number. The ID corresponds to the data in the "extension" directory.
14 document.getElementsByTagName('link')[0].href =
15 galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje';
16
17 try {
18 chrome.webstore.onInstallStageChanged.addListener(function(stage) {
19 if (stage == 'installing') {
20 if (installStarted) {
21 console.log('Received multiple "installing" stage events.');
22 window.domAutomationController.send(false);
23 }
24 installStarted = true;
25 } else if (stage == 'downloading') {
26 if (downloadStarted) {
27 console.log('Received multiple "downloading" stage events.');
28 window.domAutomationController.send(false);
29 }
30 downloadStarted = true;
31 } else {
32 console.log('Received unknown install stage event: ' + stage);
33 window.domAutomationController.send(false);
34 }
35 });
36 chrome.webstore.install(
37 undefined,
38 function() {
39 if (!downloadStarted || !installStarted) {
40 console.log('Test Failed');
41 if (!downloadStarted)
42 console.log('Did not receive "downloading" event.');
43 if (!installStarted)
44 console.log('Did not receive "installing" event.');
45 window.domAutomationController.send(false);
46 }
47 window.domAutomationController.send(true);
48 },
49 function(error) {
50 console.log('Unexpected error: ' + error);
51 window.domAutomationController.send(false);
52 });
53 // Force a garbage collection, so that if the callbacks aren't being
54 // retained properly they'll get collected and the test will fail.
55 window.gc();
56 } catch (e) {
57 console.log('Unexpected exception: ' + e);
58 console.log(e.stack);
59 window.domAutomationController.send(false);
60 throw e;
61 }
62 }
63 </script>
64
65 </body>
66 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698