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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 if (condition) { | 64 if (condition) { |
65 console.log('assertion failed: false != ' + condition); | 65 console.log('assertion failed: false != ' + condition); |
66 embedder.test.fail(); | 66 embedder.test.fail(); |
67 } | 67 } |
68 }; | 68 }; |
69 | 69 |
70 // Tests begin. | 70 // Tests begin. |
71 function testAppViewWithUndefinedDataShouldSucceed(appToEmbed) { | 71 function testAppViewWithUndefinedDataShouldSucceed(appToEmbed) { |
72 var appview = new AppView(); | 72 var appview = new AppView(); |
73 LOG('appToEmbed ' + appToEmbed); | 73 LOG('appToEmbed ' + appToEmbed); |
| 74 document.body.appendChild(appview); |
74 // Step 1: Attempt to connect to a non-existant app. | 75 // Step 1: Attempt to connect to a non-existant app. |
75 LOG('attempting to connect to non-existant app.'); | 76 LOG('attempting to connect to non-existant app.'); |
76 appview.connect('abc123', undefined, function(success) { | 77 appview.connect('abc123', undefined, function(success) { |
77 // Make sure we fail. | 78 // Make sure we fail. |
78 if (success) { | 79 if (success) { |
| 80 LOG('UNEXPECTED CONNECTION.'); |
79 embedder.test.fail(); | 81 embedder.test.fail(); |
80 return; | 82 return; |
81 } | 83 } |
82 LOG('failed to connect to non-existant app.'); | 84 LOG('failed to connect to non-existant app.'); |
83 LOG('attempting to connect to known app.'); | 85 LOG('attempting to connect to known app.'); |
84 // Step 2: Attempt to connect to an app we know exists. | 86 // Step 2: Attempt to connect to an app we know exists. |
85 appview.connect(appToEmbed, undefined, function(success) { | 87 appview.connect(appToEmbed, undefined, function(success) { |
86 // Make sure we don't fail. | 88 // Make sure we don't fail. |
87 if (!success) { | 89 if (!success) { |
| 90 LOG('FAILED TO CONNECT.'); |
88 embedder.test.fail(); | 91 embedder.test.fail(); |
89 return; | 92 return; |
90 } | 93 } |
| 94 LOG('CONNECTED.'); |
91 embedder.test.succeed(); | 95 embedder.test.succeed(); |
92 }); | 96 }); |
93 }); | 97 }); |
94 document.body.appendChild(appview); | |
95 }; | 98 }; |
96 | 99 |
97 function testAppViewRefusedDataShouldFail(appToEmbed) { | 100 function testAppViewRefusedDataShouldFail(appToEmbed) { |
98 var appview = new AppView(); | 101 var appview = new AppView(); |
99 LOG('appToEmbed ' + appToEmbed); | 102 LOG('appToEmbed ' + appToEmbed); |
| 103 document.body.appendChild(appview); |
100 LOG('Attempting to connect to app with refused params.'); | 104 LOG('Attempting to connect to app with refused params.'); |
101 appview.connect(appToEmbed, { 'foo': 'bar' }, function(success) { | 105 appview.connect(appToEmbed, { 'foo': 'bar' }, function(success) { |
102 // Make sure we fail. | 106 // Make sure we fail. |
103 if (success) { | 107 if (success) { |
| 108 LOG('UNEXPECTED CONNECTION.'); |
104 embedder.test.fail(); | 109 embedder.test.fail(); |
105 return; | 110 return; |
106 } | 111 } |
| 112 LOG('FAILED TO CONNECT.'); |
107 embedder.test.succeed(); | 113 embedder.test.succeed(); |
108 }); | 114 }); |
109 document.body.appendChild(appview); | |
110 }; | 115 }; |
111 | 116 |
112 function testAppViewGoodDataShouldSucceed(appToEmbed) { | 117 function testAppViewGoodDataShouldSucceed(appToEmbed) { |
113 var appview = new AppView(); | 118 var appview = new AppView(); |
114 LOG('appToEmbed ' + appToEmbed); | 119 LOG('appToEmbed ' + appToEmbed); |
| 120 document.body.appendChild(appview); |
115 LOG('Attempting to connect to app with good params.'); | 121 LOG('Attempting to connect to app with good params.'); |
116 // Step 2: Attempt to connect to an app with good params. | 122 // Step 2: Attempt to connect to an app with good params. |
117 appview.connect(appToEmbed, { 'foo': 'bleep' }, function(success) { | 123 appview.connect(appToEmbed, { 'foo': 'bleep' }, function(success) { |
118 // Make sure we don't fail. | 124 // Make sure we don't fail. |
119 if (!success) { | 125 if (!success) { |
| 126 LOG('FAILED TO CONNECT.'); |
120 embedder.test.fail(); | 127 embedder.test.fail(); |
121 return; | 128 return; |
122 } | 129 } |
| 130 LOG('CONNECTED.'); |
123 embedder.test.succeed(); | 131 embedder.test.succeed(); |
124 }); | 132 }); |
125 document.body.appendChild(appview); | |
126 }; | 133 }; |
127 | 134 |
128 embedder.test.testList = { | 135 embedder.test.testList = { |
129 'testAppViewWithUndefinedDataShouldSucceed': | 136 'testAppViewWithUndefinedDataShouldSucceed': |
130 testAppViewWithUndefinedDataShouldSucceed, | 137 testAppViewWithUndefinedDataShouldSucceed, |
131 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail, | 138 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail, |
132 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed | 139 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed |
133 }; | 140 }; |
134 | 141 |
135 onload = function() { | 142 onload = function() { |
136 chrome.test.getConfig(function(config) { | 143 chrome.test.getConfig(function(config) { |
137 embedder.setUp_(config); | 144 embedder.setUp_(config); |
138 chrome.test.sendMessage('Launched'); | 145 chrome.test.sendMessage('Launched'); |
139 }); | 146 }); |
140 }; | 147 }; |
OLD | NEW |