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

Unified Diff: chrome/test/data/extensions/api_test/webstore_inline_install/argument_validation.html

Issue 7795032: Add link URL and success/failure callback parameters to chrome.webstore.install() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 9 years, 3 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/argument_validation.html
diff --git a/chrome/test/data/extensions/api_test/webstore_inline_install/argument_validation.html b/chrome/test/data/extensions/api_test/webstore_inline_install/argument_validation.html
new file mode 100644
index 0000000000000000000000000000000000000000..9b87ba13f97798bc8dd488fbce541613c6b109ae
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webstore_inline_install/argument_validation.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <link rel="chrome-webstore-item">
+</head>
+<body>
+<script>
+ function runTest(galleryUrl) {
+ var storeUrl = galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje';
+ // 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 = storeUrl;
+
+ function runTests(tests) {
+ var failed = false;
+ tests.forEach(function(test) {
+ if (test.shouldPass) {
+ try {
+ test.func();
+ } catch (e) {
+ alert('unexpected exception: ' + e);
+ failed = true;
+ }
+ } else {
+ try {
+ test.func();
+ alert('unexpected pass: ' + func);
+ failed = true;
+ } catch (e) {
+ // Expected exception
+ }
+ }
+ });
+
+ window.domAutomationController.send(!failed);
+ }
+
+ function shouldPass(func) {
+ return {
+ func: func,
+ shouldPass: true
+ }
+ }
+
+ function shouldFail(func) {
+ return {
+ func: func,
+ shouldPass: false
+ }
+ }
+
+ var cwi = chrome.webstore.install;
+ runTests([
+ shouldPass(function() {cwi()}),
+ shouldPass(function() {cwi(undefined)}),
+ shouldPass(function() {cwi(undefined, undefined)}),
+ shouldPass(function() {cwi(undefined, undefined, undefined)}),
+
+ shouldPass(function() {cwi(storeUrl)}),
+ shouldPass(function() {cwi(undefined, function() {})}),
+ shouldPass(function() {cwi(undefined, undefined, function() {})}),
+
+ shouldFail(function() {cwi(123)}),
+ shouldFail(function() {cwi(undefined, 123)}),
+ shouldFail(function() {cwi(undefined, undefined, 123)})
+ ]);
+ }
+</script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698