Closed
Bug 949944
Opened 11 years ago
Closed 11 years ago
[B2G][Helix][Browser][Wallpaper] use new File([blob], filename) to return a blob with filename when picking
Categories
(Firefox OS Graveyard :: Gaia::Wallpaper, defect, P2)
Firefox OS Graveyard
Gaia::Wallpaper
Tracking
(blocking-b2g:-)
RESOLVED
FIXED
blocking-b2g | - |
People
(Reporter: johnhu, Assigned: johnhu)
References
Details
Attachments
(1 file, 9 obsolete files)
8.21 KB,
patch
|
johnhu
:
review+
|
Details | Diff | Splinter Review |
+++ This bug was initially created as a clone of Bug #920905 +++ When handling pick activity, we need to use new File([blob], filename) to return a blob with readable file name.
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → johu
Assignee | ||
Updated•11 years ago
|
Assignee | ||
Comment 1•11 years ago
|
||
nominate it as 1.3? since its original bug is 1.3?.
blocking-b2g: --- → 1.3?
Assignee | ||
Comment 2•11 years ago
|
||
Hi Baku, I found a strange error when picking from wallpaper with/without using new File([blob], filename). I had dumped the returned filename and error message: E/GeckoConsole( 2602): Content JS LOG at app://wallpaper.gaiamobile.org/js/pick.js:68 in wallpaper_pickWallpaper/img.onload/<: src resources/320x480/FXOS_Illus_Blocks.png E/GeckoConsole( 2552): [JavaScript Error: "NS_ERROR_FILE_UNRECOGNIZED_PATH: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]" {file: "jar:file:///system/b2g/omni.ja!/components/FilePicker.js" line: 194}] E/GeckoConsole( 2082): Content JS WARN at app://system.gaiamobile.org/js/activity_window.js:202 in onClose: unknown window type of activity caller. BTW, I found wallpaper returns its file name with result.name. Does that mean I don't need to return it with new File() according to [1]? [1] http://mxr.mozilla.org/mozilla-central/source/b2g/components/FilePicker.js#185
Flags: needinfo?(amarchesini)
Assignee | ||
Comment 3•11 years ago
|
||
BTW, I found another bug at [1]. We should use let file = new FileUtils.File(name); [1] http://mxr.mozilla.org/mozilla-central/source/b2g/components/FilePicker.js#194
Assignee | ||
Comment 4•11 years ago
|
||
Baku, I did some tests and found the "new FileUtils.File()" needs absolute file path. So, I use pure JavaScript to take the file name out. Any suggestions?
Comment 5•11 years ago
|
||
This is an approach that works for B2G. So I guess it's fine. I want to have fabrice to review this patch.
Flags: needinfo?(amarchesini)
Assignee | ||
Comment 6•11 years ago
|
||
Fabrice, Please review this patch, according to the suggestion of baku at comment 5. The main thought of this patch is to use javascript function to take the filename out instead of FileUtils.File().
Attachment #8347939 -
Attachment is obsolete: true
Attachment #8348493 -
Flags: review?(fabrice)
Comment 7•11 years ago
|
||
Comment on attachment 8348493 [details] [diff] [review] bug-949944-fix.patch Review of attachment 8348493 [details] [diff] [review]: ----------------------------------------------------------------- ::: b2g/components/FilePicker.js @@ +190,5 @@ > } > > // Let's try to remove the full path and take just the filename. > if (name) { > + name = name.substr(name.lastIndexOf('/') + 1); this will not work on windows, which we support in desktop builds.
Attachment #8348493 -
Flags: review?(fabrice) → review-
Assignee | ||
Comment 8•11 years ago
|
||
Thank you for telling me this. I thought b2g folder is only for b2g project in the past. I think I am wrong about it. b2g folder may also be used in b2g-desktop and others. This patch uses OS.Path.split to get the filename. Please review it, thanks.
Attachment #8348493 -
Attachment is obsolete: true
Attachment #8349848 -
Flags: review?(fabrice)
Comment 9•11 years ago
|
||
Comment on attachment 8349848 [details] [diff] [review] bug-949944-fix-v2.patch Review of attachment 8349848 [details] [diff] [review]: ----------------------------------------------------------------- Can we get tests for that?
Attachment #8349848 -
Flags: review?(fabrice) → review+
Comment 10•11 years ago
|
||
Comment on attachment 8349848 [details] [diff] [review] bug-949944-fix-v2.patch Review of attachment 8349848 [details] [diff] [review]: ----------------------------------------------------------------- ::: b2g/components/FilePicker.js @@ +32,4 @@ > 'audio/webm']; > > Cu.import('resource://gre/modules/XPCOMUtils.jsm'); > +Cu.import('resource://gre/modules/FileUtils.jsm'); Do we need this line?
Assignee | ||
Comment 11•11 years ago
|
||
(In reply to Andrea Marchesini (:baku) from comment #10) > > +Cu.import('resource://gre/modules/FileUtils.jsm'); > > Do we need this line? No, we don't need this line. I will remove it.
Updated•11 years ago
|
Component: Gaia → Gaia::Wallpaper
Assignee | ||
Comment 12•11 years ago
|
||
Ok, I will try to write tests for this patch....
Assignee | ||
Comment 13•11 years ago
|
||
Remove the useless import, as per comment 10, and move the r+ here.
Attachment #8349848 -
Attachment is obsolete: true
Attachment #8350463 -
Flags: review+
Assignee | ||
Comment 14•11 years ago
|
||
Fabrice, I had merged the tests into the patch. Please review it again. And Shih-Chiang Chien told me that this test needs to run at OOP environment to have correct result. So, I only put tests into b2g and b2g-debug. Thanks.
Attachment #8351352 -
Flags: review?(fabrice)
Assignee | ||
Comment 15•11 years ago
|
||
Found additional spaces at v4.
Attachment #8350463 -
Attachment is obsolete: true
Attachment #8351352 -
Attachment is obsolete: true
Attachment #8351352 -
Flags: review?(fabrice)
Assignee | ||
Comment 16•11 years ago
|
||
Comment on attachment 8351354 [details] [diff] [review] bug-949944-v4.1.patch Fabrice, I had merged the tests into the patch. Please review it again. And Shih-Chiang Chien told me that this test needs to run at OOP environment to have correct result. So, I only put tests into b2g and b2g-debug. Thanks
Attachment #8351354 -
Flags: review?(fabrice)
Assignee | ||
Comment 17•11 years ago
|
||
Attachment #8351354 -
Attachment is obsolete: true
Attachment #8351354 -
Flags: review?(fabrice)
Assignee | ||
Comment 18•11 years ago
|
||
Comment on attachment 8351355 [details] [diff] [review] bug-949944-v5.patch Fabrice, I had merged the tests into the patch. Please review it again. And Shih-Chiang Chien told me that this test needs to run at OOP environment to have correct result. So, I only put tests into b2g and b2g-debug. Thanks
Attachment #8351355 -
Flags: review?(fabrice)
Comment 19•11 years ago
|
||
Comment on attachment 8351355 [details] [diff] [review] bug-949944-v5.patch Review of attachment 8351355 [details] [diff] [review]: ----------------------------------------------------------------- That looks good, thanks! Can you check the windows path before landing? ::: b2g/components/test/mochitest/filepicker_path_handler_chrome.js @@ +8,5 @@ > +const Ci = Components.interfaces; > + > +// use ppmm to handle file-picker message. > +let ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'] > + .getService(Ci.nsIMessageListenerManager); nit: align .getService() with ['..'] ::: b2g/components/test/mochitest/test_filepicker_path.html @@ +17,5 @@ > + > +var testCases = [ > + // case 1: returns blob with name > + { pickedResult: { success: true, > + result: { nit: indentation is wrong (align 'success' and 'result') @@ +65,5 @@ > + name: 'test5.txt' > + } > + }, > + fileName: 'test5.txt'}, > + // case 6: returns file without name. This case may be failed because we nit: This case may fail @@ +120,5 @@ > + var name = activeTestCase.pickedResult.result.name; > + name = name.replace('/', '\\'); > + if (name.startWidth('\\')) { > + name = 'C:' + name; > + } hm, this windows specific part is a bit ugly. Can you check if other tests do something else in these situations?
Attachment #8351355 -
Flags: review?(fabrice) → feedback+
Assignee | ||
Comment 20•11 years ago
|
||
Thanks for your reviews, Fabrice. As to the windows specific part, that's for building the expected result. I had found another one using the same syntax[1], so I use the same way. I don't know if there any other better way. If you know it, please tell me and I will update the patch of it. I am not sure about one thing: with this patch, the mochitests under b2g/components folder is only enabled in b2g and b2g-debug. So, those tests are not run at b2g-desktop and the windows parts are useless, aren't they?? If yes, I will remove those ugly codes. Thanks. [1] http://dxr.mozilla.org/mozilla-central/source/toolkit/content/tests/browser/browser_input_file_tooltips.js#22
Flags: needinfo?(fabrice)
Comment 21•11 years ago
|
||
Ok. Your tests will run on b2g-desktop, so keep the windows part. b2g/b2g-debug just means "opt build"/"debug build", but they will run on desktop.
Flags: needinfo?(fabrice)
Updated•11 years ago
|
Attachment #8351355 -
Flags: feedback+ → review+
Assignee | ||
Comment 22•11 years ago
|
||
This patch only fixes the nits mentioned in comment 19. Move r+ to this one.
Attachment #8351355 -
Attachment is obsolete: true
Attachment #8356931 -
Flags: review+
Assignee | ||
Comment 23•11 years ago
|
||
conflict found while testing in the try server. this is the rebased version.
Attachment #8356931 -
Attachment is obsolete: true
Attachment #8357604 -
Flags: review+
Assignee | ||
Comment 24•11 years ago
|
||
Attachment #8357604 -
Attachment is obsolete: true
Attachment #8357606 -
Flags: review+
Comment 25•11 years ago
|
||
The result of try server: https://tbpl.mozilla.org/?tree=Try&rev=3339103da9ea
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 26•11 years ago
|
||
This doesn't seem like something we'd hold 1.3 for but please request aurora uplift approval when ready.
blocking-b2g: 1.3? → -
Comment 27•11 years ago
|
||
https://hg.mozilla.org/integration/b2g-inbound/rev/6b4dbc268a68
Flags: in-testsuite+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/6b4dbc268a68
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•