| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 reader.onerror = function(e) { | 86 reader.onerror = function(e) { |
| 87 errorCallback({message: "Unable to read file."}); | 87 errorCallback({message: "Unable to read file."}); |
| 88 }; | 88 }; |
| 89 entry.file(function(file) { | 89 entry.file(function(file) { |
| 90 reader.readAsText(file); | 90 reader.readAsText(file); |
| 91 }, | 91 }, |
| 92 errorCallback); | 92 errorCallback); |
| 93 } | 93 } |
| 94 | 94 |
| 95 function executeListener(id, details) { | 95 function executeListener(id, details) { |
| 96 if (id != "TextAction" && id != "BaseAction" && id != "JpegAction") { | 96 if (id != "AbcAction" && id != "BaseAction" && id != "123Action") { |
| 97 chrome.test.fail("Unexpected action id: " + id); | 97 chrome.test.fail("Unexpected action id: " + id); |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 var file_entries = details.entries; | 100 var file_entries = details.entries; |
| 101 if (!file_entries || file_entries.length != 1) { | 101 if (!file_entries || file_entries.length != 1) { |
| 102 chrome.test.fail("Unexpected file url list"); | 102 chrome.test.fail("Unexpected file url list"); |
| 103 return; | 103 return; |
| 104 } | 104 } |
| 105 chrome.tabs.get(details.tab_id, function(tab) { | 105 chrome.tabs.get(details.tab_id, function(tab) { |
| 106 if (tab.title != "file browser component test") { | 106 if (tab.title != "file browser component test") { |
| 107 chrome.test.fail("Unexpected tab title: " + tab.title); | 107 chrome.test.fail("Unexpected tab title: " + tab.title); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 runFileSystemHandlerTest(file_entries); | 110 runFileSystemHandlerTest(file_entries); |
| 111 }); | 111 }); |
| 112 } | 112 } |
| 113 | 113 |
| 114 chrome.fileBrowserHandler.onExecute.addListener(executeListener); | 114 chrome.fileBrowserHandler.onExecute.addListener(executeListener); |
| 115 | 115 |
| 116 // This extension just initializes its chrome.fileBrowserHandler.onExecute | 116 // This extension just initializes its chrome.fileBrowserHandler.onExecute |
| 117 // event listener, the real testing is done when this extension's handler is | 117 // event listener, the real testing is done when this extension's handler is |
| 118 // invoked from filebrowser_component tests. This event will be raised from that | 118 // invoked from filebrowser_component tests. This event will be raised from that |
| 119 // component extension test and it simulates user action in the file browser. | 119 // component extension test and it simulates user action in the file browser. |
| 120 // tab.html part of this extension can run only after the component raises this | 120 // tab.html part of this extension can run only after the component raises this |
| 121 // event, since that operation sets the propery security context and creates | 121 // event, since that operation sets the propery security context and creates |
| 122 // event's payload with proper file Entry instances. tab.html will return | 122 // event's payload with proper file Entry instances. tab.html will return |
| 123 // results of its execution to filebrowser_component test through a | 123 // results of its execution to filebrowser_component test through a |
| 124 // cross-component message. | 124 // cross-component message. |
| 125 chrome.test.succeed(); | 125 chrome.test.succeed(); |
| OLD | NEW |