1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/b2g/components/test/mochitest/filepicker_path_handler_chrome.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 +* License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 +* You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +'use strict'; 1.9 + 1.10 +const Cc = Components.classes; 1.11 +const Ci = Components.interfaces; 1.12 + 1.13 +// use ppmm to handle file-picker message. 1.14 +let ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'] 1.15 + .getService(Ci.nsIMessageListenerManager); 1.16 + 1.17 +let pickResult = null; 1.18 + 1.19 +function processPickMessage(message) { 1.20 + let sender = message.target.QueryInterface(Ci.nsIMessageSender); 1.21 + // reply FilePicker's message 1.22 + sender.sendAsyncMessage('file-picked', pickResult); 1.23 + // notify caller 1.24 + sendAsyncMessage('file-picked-posted', { type: 'file-picked-posted' }); 1.25 +} 1.26 + 1.27 +function updatePickResult(result) { 1.28 + pickResult = result; 1.29 + sendAsyncMessage('pick-result-updated', { type: 'pick-result-updated' }); 1.30 +} 1.31 + 1.32 +ppmm.addMessageListener('file-picker', processPickMessage); 1.33 +// use update-pick-result to change the expected pick result. 1.34 +addMessageListener('update-pick-result', updatePickResult);