- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / launch_file_by_extension_and_type / test.js
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 chrome.app.runtime.onLaunched.addListener(function (launchData) {
6   // Test that the isKioskSession field is |false| and the id and items fields
7   // can be read in the launch data.
8   chrome.test.runTests([
9     function testFileHandler() {
10       chrome.test.assertFalse(!launchData, "No launchData");
11       chrome.test.assertFalse(launchData.isKioskSession,
12           "launchData.isKioskSession incorrect");
13       chrome.test.assertEq(launchData.id, "text",
14           "launchData.id incorrect");
15       chrome.test.assertEq(launchData.items.length, 1);
16       chrome.test.assertTrue(
17           chrome.fileSystem.retainEntry(launchData.items[0].entry) != null);
18
19       launchData.items[0].entry.file(function(file) {
20         var reader = new FileReader();
21         reader.onloadend = function(e) {
22           chrome.test.assertEq(
23               reader.result.indexOf("This is a test. Word."), 0);
24           chrome.test.succeed();
25         };
26         reader.onerror = function(e) {
27           chrome.test.fail("Error reading file contents.");
28         };
29         reader.readAsText(file);
30       });
31     }
32   ]);
33 });