Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Test that there is a launchData.intent, it is set up proerly, and that the | |
| 6 // FileEntry in launchData.intent.data can be read. | |
| 7 function onLaunched(launchData) { | |
| 8 chrome.test.runTests([ | |
| 9 function testIntent() { | |
| 10 chrome.test.assertFalse(!launchData, "No launchData"); | |
| 11 chrome.test.assertFalse(!launchData.intent, "No launchData.intent"); | |
| 12 chrome.test.assertTrue( | |
|
Mihai Parparita -not on Chrome
2012/05/18 04:26:04
You can use chrome.test.assertEq, so that you don'
benwells
2012/05/22 13:15:03
Done.
| |
| 13 launchData.intent.action == "http://webintents.org/view", | |
| 14 "launchData.intent.action incorrect: " + launchData.intent.action); | |
| 15 chrome.test.assertTrue(launchData.intent.type == "text/plain", | |
| 16 "launchData.intent.type incorrect: " + launchData.intent.type); | |
| 17 chrome.test.assertFalse(!launchData.intent.data, | |
| 18 "No launchData.intent.data"); | |
| 19 | |
| 20 launchData.intent.data.file(function(file) { | |
| 21 var reader = new FileReader(); | |
| 22 reader.onloadend = function(e) { | |
| 23 chrome.test.assertTrue( | |
| 24 reader.result.indexOf("This is a test. Word.") == 0, | |
| 25 "File contents incorrect: " + reader.result); | |
| 26 chrome.test.succeed(); | |
| 27 }; | |
| 28 reader.onerror = function(e) { | |
| 29 chrome.test.fail("Error reading file contents."); | |
| 30 }; | |
| 31 reader.readAsText(file); | |
| 32 }); | |
| 33 } | |
| 34 ]); | |
| 35 } | |
| 36 | |
| 37 chrome.experimental.app.onLaunched.addListener(onLaunched); | |
| OLD | NEW |