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 /* | 5 /* |
6 This extension is a file intent handler and does the following during the test: | 6 This extension is a file intent handler and does the following during the test: |
7 | 7 |
8 1. It first registers content hander. | 8 1. It first registers content hander. |
9 2. When content handler callback is invoked, opens tab.html page and passes | 9 2. When content handler callback is invoked, opens tab.html page and passes |
10 file url via hash ref. | 10 file url via hash ref. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 function readEntryByUrl(entryUrl) { | 82 function readEntryByUrl(entryUrl) { |
83 window.webkitResolveLocalFileSystemURL(entryUrl, onGotEntryByUrl, | 83 window.webkitResolveLocalFileSystemURL(entryUrl, onGotEntryByUrl, |
84 errorCallback); | 84 errorCallback); |
85 }; | 85 }; |
86 | 86 |
87 // Try reading another file that has the same name as the entry we got from the | 87 // Try reading another file that has the same name as the entry we got from the |
88 // executed task, but .log extension instead of .tXt. | 88 // executed task, but .log extension instead of .tXt. |
89 // The .log file is created by fileBrowser component extension. | 89 // The .log file is created by fileBrowser component extension. |
90 // We should not be able to get this file's fileEntry. | 90 // We should not be able to get this file's fileEntry. |
91 function tryOpeningLogFile(origEntry,successCallback, errorCallback) { | 91 function tryOpeningLogFile(origEntry,successCallback, errorCallback) { |
92 var logFilePath =origEntry.fullPath.replace('.tXt', '.log'); | 92 var logFilePath = origEntry.fullPath.replace('.aBc', '.log'); |
93 origEntry.filesystem.root.getFile(logFilePath, {}, | 93 origEntry.filesystem.root.getFile(logFilePath, {}, |
94 successCallback, | 94 successCallback, |
95 errorCallback); | 95 errorCallback); |
96 }; | 96 }; |
97 | 97 |
98 function onLogFileOpened(file) { | 98 function onLogFileOpened(file) { |
99 errorCallback({message: "Opened file for which we don't have permission."}); | 99 errorCallback({message: "Opened file for which we don't have permission."}); |
100 }; | 100 }; |
101 | 101 |
102 // Try reading content of the received file. | 102 // Try reading content of the received file. |
(...skipping 22 matching lines...) Expand all Loading... |
125 } | 125 } |
126 var entry = entries[0]; | 126 var entry = entries[0]; |
127 | 127 |
128 // This operation should fail. If it does, we continue with testing. | 128 // This operation should fail. If it does, we continue with testing. |
129 tryOpeningLogFile(entry, onLogFileOpened, | 129 tryOpeningLogFile(entry, onLogFileOpened, |
130 tryReadingReceivedFile.bind(this, entry)); | 130 tryReadingReceivedFile.bind(this, entry)); |
131 | 131 |
132 }; | 132 }; |
133 | 133 |
134 function executeListener(id, details) { | 134 function executeListener(id, details) { |
135 if (id != "TextAction" && id != "BaseAction" && id != "JpegAction") { | 135 if (id != "AbcAction" && id != "BaseAction" && id != "123Action") { |
136 chrome.test.fail("Unexpected action id: " + id); | 136 chrome.test.fail("Unexpected action id: " + id); |
137 return; | 137 return; |
138 } | 138 } |
139 var file_entries = details.entries; | 139 var file_entries = details.entries; |
140 if (!file_entries || file_entries.length != 1) { | 140 if (!file_entries || file_entries.length != 1) { |
141 chrome.test.fail("Unexpected file url list"); | 141 chrome.test.fail("Unexpected file url list"); |
142 return; | 142 return; |
143 } | 143 } |
144 chrome.tabs.get(details.tab_id, function(tab) { | 144 chrome.tabs.get(details.tab_id, function(tab) { |
145 if (tab.title != "file browser component test") { | 145 if (tab.title != "file browser component test") { |
146 chrome.test.fail("Unexpected tab title: " + tab.title); | 146 chrome.test.fail("Unexpected tab title: " + tab.title); |
147 return; | 147 return; |
148 } | 148 } |
149 runFileSystemHandlerTest(file_entries); | 149 runFileSystemHandlerTest(file_entries); |
150 }); | 150 }); |
151 } | 151 } |
152 | 152 |
153 chrome.fileBrowserHandler.onExecute.addListener(executeListener); | 153 chrome.fileBrowserHandler.onExecute.addListener(executeListener); |
154 | 154 |
155 // This extension just initializes its chrome.fileBrowserHandler.onExecute | 155 // This extension just initializes its chrome.fileBrowserHandler.onExecute |
156 // event listener, the real testing is done when this extension's handler is | 156 // event listener, the real testing is done when this extension's handler is |
157 // invoked from filebrowser_component tests. This event will be raised from that | 157 // invoked from filebrowser_component tests. This event will be raised from that |
158 // component extension test and it simulates user action in the file browser. | 158 // component extension test and it simulates user action in the file browser. |
159 // tab.html part of this extension can run only after the component raises this | 159 // tab.html part of this extension can run only after the component raises this |
160 // event, since that operation sets the propery security context and creates | 160 // event, since that operation sets the propery security context and creates |
161 // event's payload with proper file Entry instances. tab.html will return | 161 // event's payload with proper file Entry instances. tab.html will return |
162 // results of its execution to filebrowser_component test through a | 162 // results of its execution to filebrowser_component test through a |
163 // cross-component message. | 163 // cross-component message. |
164 chrome.test.succeed(); | 164 chrome.test.succeed(); |
OLD | NEW |