4 <link rel="chrome-webstore-item">
8 console.log('Page loaded');
10 function runTest(galleryUrl, index) {
11 var storeUrl = galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje';
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 = storeUrl;
16 function shouldPass(func) {
23 function shouldFail(func) {
30 var cwi = chrome.webstore.install;
31 var callback = function() {
35 shouldPass(function() {cwi()}),
36 shouldPass(function() {cwi(undefined)}),
37 shouldPass(function() {cwi(undefined, undefined)}),
38 shouldPass(function() {cwi(undefined, undefined, undefined)}),
40 shouldPass(function() {cwi(storeUrl)}),
41 shouldPass(function() {cwi(undefined, callback)}),
42 shouldPass(function() {cwi(undefined, undefined, callback)}),
43 shouldPass(function() {cwi(undefined, callback, callback)}),
45 shouldFail(function() {cwi(callback)}),
46 shouldFail(function() {cwi(callback, callback)}),
47 shouldFail(function() {cwi(callback, callback, callback)}),
49 shouldFail(function() {cwi(123)}),
50 shouldFail(function() {cwi(undefined, 123)}),
51 shouldFail(function() {cwi(undefined, undefined, 123)}),
52 shouldFail(function() {cwi(undefined, callback, 123)})
55 var successResult = (index < testCases.length - 1 ? 'KEEPGOING' : 'DONE');
56 var failureResult = 'FAILED';
58 function runTestCase(test) {
60 console.log('Testing ' + test.func);
61 if (test.shouldPass) {
65 console.log('unexpected exception: ' + e);
71 console.log('unexpected pass: ' + func);
78 console.log('Ran test, sending response');
79 window.domAutomationController.send(failed ? failureResult : successResult);
80 console.log('Test complete');
83 runTestCase(testCases[index]);