b2g/components/test/mochitest/filepicker_path_handler_chrome.js

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:47a6e1282143
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 'use strict';
6
7 const Cc = Components.classes;
8 const Ci = Components.interfaces;
9
10 // use ppmm to handle file-picker message.
11 let ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1']
12 .getService(Ci.nsIMessageListenerManager);
13
14 let pickResult = null;
15
16 function processPickMessage(message) {
17 let sender = message.target.QueryInterface(Ci.nsIMessageSender);
18 // reply FilePicker's message
19 sender.sendAsyncMessage('file-picked', pickResult);
20 // notify caller
21 sendAsyncMessage('file-picked-posted', { type: 'file-picked-posted' });
22 }
23
24 function updatePickResult(result) {
25 pickResult = result;
26 sendAsyncMessage('pick-result-updated', { type: 'pick-result-updated' });
27 }
28
29 ppmm.addMessageListener('file-picker', processPickMessage);
30 // use update-pick-result to change the expected pick result.
31 addMessageListener('update-pick-result', updatePickResult);

mercurial