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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/webstore_inline_install/install_stage_listener.html
diff --git a/chrome/test/data/extensions/api_test/webstore_inline_install/install_stage_listener.html b/chrome/test/data/extensions/api_test/webstore_inline_install/install_stage_listener.html
new file mode 100644
index 0000000000000000000000000000000000000000..ba1547aacec15d93bce92d0e01b077fc14afb8c1
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webstore_inline_install/install_stage_listener.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <link rel="chrome-webstore-item">
+</head>
+<body>
+<script>
+ function runTest(galleryUrl) {
+ var downloadStarted = false;
+ var installStarted = false;
+
+ // Link URL has to be generated dynamically in order to include the right
+ // port number. The ID corresponds to the data in the "extension" directory.
+ document.getElementsByTagName('link')[0].href =
+ galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje';
+
+ try {
+ chrome.webstore.onInstallStageChanged.addListener(function(stage) {
+ if (stage == 'installing') {
+ if (installStarted) {
+ console.log('Received multiple "installing" stage events.');
+ window.domAutomationController.send(false);
+ }
+ installStarted = true;
+ } else if (stage == 'downloading') {
+ if (downloadStarted) {
+ console.log('Received multiple "downloading" stage events.');
+ window.domAutomationController.send(false);
+ }
+ downloadStarted = true;
+ } else {
+ console.log('Received unknown install stage event: ' + stage);
+ window.domAutomationController.send(false);
+ }
+ });
+ chrome.webstore.install(
+ undefined,
+ function() {
+ if (!downloadStarted || !installStarted) {
+ console.log('Test Failed');
+ if (!downloadStarted)
+ console.log('Did not receive "downloading" event.');
+ if (!installStarted)
+ console.log('Did not receive "installing" event.');
+ window.domAutomationController.send(false);
+ }
+ window.domAutomationController.send(true);
+ },
+ function(error) {
+ console.log('Unexpected error: ' + error);
+ window.domAutomationController.send(false);
+ });
+ // Force a garbage collection, so that if the callbacks aren't being
+ // retained properly they'll get collected and the test will fail.
+ window.gc();
+ } catch (e) {
+ console.log('Unexpected exception: ' + e);
+ console.log(e.stack);
+ window.domAutomationController.send(false);
+ throw e;
+ }
+ }
+</script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698