OLD | NEW |
(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 // Link URL has to be generated dynamically in order to include the right |
| 10 // port number. The ID corresponds to the data in the "extension" directory. |
| 11 document.getElementsByTagName('link')[0].href = |
| 12 galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje'; |
| 13 |
| 14 try { |
| 15 chrome.webstore.install( |
| 16 undefined, |
| 17 function() {}, |
| 18 function() {}); |
| 19 chrome.webstore.install( |
| 20 undefined, |
| 21 function() { |
| 22 console.log('Unexpected success'); |
| 23 window.domAutomationController.send(false); |
| 24 }, |
| 25 function(errorMessage, errorCode) { |
| 26 var success = errorCode == 3; // Install in progress error. |
| 27 if (!success) |
| 28 console.log('Unexpected error: ' + errorMessage); |
| 29 window.domAutomationController.send(success); |
| 30 }); |
| 31 } catch (e) { |
| 32 // Yuck. We can throw this "already installing" error either from the |
| 33 // renderer (if we catch the fact that it's already installing early) or |
| 34 // from the browser. In the first case, it's a thrown error, and in the |
| 35 // second, it triggers the callback from chrome.webstore.install. And to |
| 36 // top it off, they're different messages. Unfortunately, it's hard to say |
| 37 // which, if either, we can change, since someone may be relying on one or |
| 38 // the other. |
| 39 // TODO(devlin): Make this less bad somehow. crbug.com/624614 |
| 40 var success = |
| 41 e.message == 'A Chrome Web Store installation is already pending.'; |
| 42 if (!success) |
| 43 console.log('Unexpected exception: ' + e); |
| 44 window.domAutomationController.send(success); |
| 45 } |
| 46 } |
| 47 </script> |
| 48 |
| 49 </body> |
| 50 </html> |
OLD | NEW |