OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var util = {}; | 5 var util = {}; |
6 var embedder = {}; | 6 var embedder = {}; |
7 embedder.baseGuestURL = ''; | 7 embedder.baseGuestURL = ''; |
8 embedder.emptyGuestURL = ''; | 8 embedder.emptyGuestURL = ''; |
9 embedder.windowOpenGuestURL = ''; | 9 embedder.windowOpenGuestURL = ''; |
10 embedder.noReferrerGuestURL = ''; | 10 embedder.noReferrerGuestURL = ''; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 embedder.test.fail(); | 66 embedder.test.fail(); |
67 } | 67 } |
68 }; | 68 }; |
69 | 69 |
70 // Tests begin. | 70 // Tests begin. |
71 function testAppViewBasic(appToEmbed) { | 71 function testAppViewBasic(appToEmbed) { |
72 var appview = new AppView(); | 72 var appview = new AppView(); |
73 LOG('appToEmbed ' + appToEmbed); | 73 LOG('appToEmbed ' + appToEmbed); |
74 // Step 1: Attempt to connect to a non-existant app. | 74 // Step 1: Attempt to connect to a non-existant app. |
75 LOG('attempting to connect to non-existant app.'); | 75 LOG('attempting to connect to non-existant app.'); |
76 appview.connect('abc123', function(success) { | 76 appview.connect('abc123', {}, function(success) { |
77 // Make sure we fail. | 77 // Make sure we fail. |
78 if (success) { | 78 if (success) { |
79 embedder.test.fail(); | 79 embedder.test.fail(); |
80 return; | 80 return; |
81 } | 81 } |
82 LOG('failed to connect to non-existant app.'); | 82 LOG('failed to connect to non-existant app.'); |
83 LOG('attempting to connect to known app.'); | 83 LOG('attempting to connect to known app.'); |
84 // Step 2: Attempt to connect to an app we know exists. | 84 // Step 2: Attempt to connect to an app we know exists. |
85 appview.connect(appToEmbed, function(success) { | 85 appview.connect(appToEmbed, {}, function(success) { |
86 // Make sure we don't fail. | 86 // Make sure we don't fail. |
87 if (!success) { | 87 if (!success) { |
88 embedder.test.fail(); | 88 embedder.test.fail(); |
89 return; | 89 return; |
90 } | 90 } |
91 embedder.test.succeed(); | 91 embedder.test.succeed(); |
92 }); | 92 }); |
93 }); | 93 }); |
94 document.body.appendChild(appview); | 94 document.body.appendChild(appview); |
95 }; | 95 }; |
96 | 96 |
| 97 function testAppViewRefusedDataShouldFail(appToEmbed) { |
| 98 var appview = new AppView(); |
| 99 LOG('appToEmbed ' + appToEmbed); |
| 100 LOG('Attempting to connect to app with refused params.'); |
| 101 appview.connect(appToEmbed, { 'foo': 'bar' }, function(success) { |
| 102 // Make sure we fail. |
| 103 if (success) { |
| 104 embedder.test.fail(); |
| 105 return; |
| 106 } |
| 107 embedder.test.succeed(); |
| 108 }); |
| 109 document.body.appendChild(appview); |
| 110 }; |
| 111 |
| 112 function testAppViewGoodDataShouldSucceed(appToEmbed) { |
| 113 var appview = new AppView(); |
| 114 LOG('appToEmbed ' + appToEmbed); |
| 115 LOG('Attempting to connect to app with good params.'); |
| 116 // Step 2: Attempt to connect to an app with good params. |
| 117 appview.connect(appToEmbed, { 'foo': 'bleep' }, function(success) { |
| 118 // Make sure we don't fail. |
| 119 if (!success) { |
| 120 embedder.test.fail(); |
| 121 return; |
| 122 } |
| 123 embedder.test.succeed(); |
| 124 }); |
| 125 document.body.appendChild(appview); |
| 126 }; |
| 127 |
97 embedder.test.testList = { | 128 embedder.test.testList = { |
98 'testAppViewBasic': testAppViewBasic | 129 'testAppViewBasic': testAppViewBasic, |
| 130 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail, |
| 131 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed |
99 }; | 132 }; |
100 | 133 |
101 onload = function() { | 134 onload = function() { |
102 chrome.test.getConfig(function(config) { | 135 chrome.test.getConfig(function(config) { |
103 embedder.setUp_(config); | 136 embedder.setUp_(config); |
104 chrome.test.sendMessage('Launched'); | 137 chrome.test.sendMessage('Launched'); |
105 }); | 138 }); |
106 }; | 139 }; |
OLD | NEW |