| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Test that there is a launchData.intent, it is set up proerly, and that the | 5 chrome.app.runtime.onLaunched.addListener(function (launchData) { |
| 6 // FileEntry in launchData.intent.data can be read. | 6 // Test that there is a launchData.intent, it is set up proerly, and that the |
| 7 function onLaunched(launchData) { | 7 // FileEntry in launchData.intent.data can be read. |
| 8 chrome.test.runTests([ | 8 chrome.test.runTests([ |
| 9 function testIntent() { | 9 function testIntent() { |
| 10 chrome.test.assertFalse(!launchData, "No launchData"); | 10 chrome.test.assertFalse(!launchData, "No launchData"); |
| 11 chrome.test.assertFalse(!launchData.intent, "No launchData.intent"); | 11 chrome.test.assertFalse(!launchData.intent, "No launchData.intent"); |
| 12 chrome.test.assertEq(launchData.intent.action, | 12 chrome.test.assertEq(launchData.intent.action, |
| 13 "http://webintents.org/view"); | 13 "http://webintents.org/view"); |
| 14 chrome.test.assertEq(launchData.intent.type, | 14 chrome.test.assertEq(launchData.intent.type, |
| 15 "chrome-extension://fileentry"); | 15 "chrome-extension://fileentry"); |
| 16 chrome.test.assertFalse(!launchData.intent.data, | 16 chrome.test.assertFalse(!launchData.intent.data, |
| 17 "No launchData.intent.data"); | 17 "No launchData.intent.data"); |
| 18 | 18 |
| 19 launchData.intent.data.file(function(file) { | 19 launchData.intent.data.file(function(file) { |
| 20 var reader = new FileReader(); | 20 var reader = new FileReader(); |
| 21 reader.onloadend = function(e) { | 21 reader.onloadend = function(e) { |
| 22 chrome.test.assertEq( | 22 chrome.test.assertEq( |
| 23 reader.result.indexOf("This is a test. Word."), 0); | 23 reader.result.indexOf("This is a test. Word."), 0); |
| 24 chrome.test.succeed(); | 24 chrome.test.succeed(); |
| 25 }; | 25 }; |
| 26 reader.onerror = function(e) { | 26 reader.onerror = function(e) { |
| 27 chrome.test.fail("Error reading file contents."); | 27 chrome.test.fail("Error reading file contents."); |
| 28 }; | 28 }; |
| 29 reader.readAsText(file); | 29 reader.readAsText(file); |
| 30 }); | 30 }); |
| 31 } | 31 } |
| 32 ]); | 32 ]); |
| 33 } | 33 }); |
| 34 | |
| 35 chrome.experimental.app.onLaunched.addListener(onLaunched); | |
| OLD | NEW |