OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // The id of an extension we're using for install tests. | 5 // The id of an extension we're using for install tests. |
6 var extensionId = "enfkhcelefdadlmkffamgdlgplcionje"; | 6 var extensionId = "enfkhcelefdadlmkffamgdlgplcionje"; |
7 | 7 |
8 // The id of an app we're using for install tests. | 8 // The id of an app we're using for install tests. |
9 var appId = "iladmdjkfniedhfhcfoefgojhgaiaccc"; | 9 var appId = "iladmdjkfniedhfhcfoefgojhgaiaccc"; |
10 | 10 |
11 var assertEq = chrome.test.assertEq; | 11 var assertEq = chrome.test.assertEq; |
| 12 var assertFalse = chrome.test.assertFalse; |
12 var assertNoLastError = chrome.test.assertNoLastError; | 13 var assertNoLastError = chrome.test.assertNoLastError; |
13 var assertTrue = chrome.test.assertTrue; | 14 var assertTrue = chrome.test.assertTrue; |
14 var callbackFail = chrome.test.callbackFail; | 15 var callbackFail = chrome.test.callbackFail; |
15 var callbackPass = chrome.test.callbackPass; | 16 var callbackPass = chrome.test.callbackPass; |
16 var listenOnce = chrome.test.listenOnce; | 17 var listenOnce = chrome.test.listenOnce; |
17 var runTests = chrome.test.runTests; | 18 var runTests = chrome.test.runTests; |
18 var succeed = chrome.test.succeed; | 19 var succeed = chrome.test.succeed; |
19 | 20 |
20 // Calls |callback| with true/false indicating whether an item with the |id| | 21 // Calls |callback| with true/false indicating whether an item with the |id| |
21 // is installed. | 22 // is installed. |
(...skipping 29 matching lines...) Expand all Loading... |
51 var ctx = canvas.getContext("2d"); | 52 var ctx = canvas.getContext("2d"); |
52 ctx.drawImage(img, 0, 0); | 53 ctx.drawImage(img, 0, 0); |
53 var tmp = canvas.toDataURL(); | 54 var tmp = canvas.toDataURL(); |
54 // Strip the data url prefix to just get the base64-encoded bytes. | 55 // Strip the data url prefix to just get the base64-encoded bytes. |
55 cachedIcon = tmp.slice(tmp.search(",")+1); | 56 cachedIcon = tmp.slice(tmp.search(",")+1); |
56 callback(cachedIcon); | 57 callback(cachedIcon); |
57 }; | 58 }; |
58 img.src = "extension/icon.png"; | 59 img.src = "extension/icon.png"; |
59 } | 60 } |
60 | 61 |
61 var cachedManifest = null; | |
62 | |
63 // This returns the string contents of the extension's manifest file. | 62 // This returns the string contents of the extension's manifest file. |
64 function getManifest(alternativePath) { | 63 function getManifest(alternativePath) { |
65 if (cachedManifest) | |
66 return cachedManifest; | |
67 | |
68 // Do a synchronous XHR to get the manifest. | 64 // Do a synchronous XHR to get the manifest. |
69 var xhr = new XMLHttpRequest(); | 65 var xhr = new XMLHttpRequest(); |
70 xhr.open("GET", | 66 xhr.open("GET", |
71 alternativePath ? alternativePath : "extension/manifest.json", | 67 alternativePath ? alternativePath : "extension/manifest.json", |
72 false); | 68 false); |
73 xhr.send(null); | 69 xhr.send(null); |
74 return xhr.responseText; | 70 return xhr.responseText; |
75 } | 71 } |
OLD | NEW |