|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 var MockFilePicker = SpecialPowers.MockFilePicker; |
|
5 MockFilePicker.init(window); |
|
6 |
|
7 /** |
|
8 * TestCase for bug 564387 |
|
9 * <https://bugzilla.mozilla.org/show_bug.cgi?id=564387> |
|
10 */ |
|
11 function test() { |
|
12 waitForExplicitFinish(); |
|
13 var fileName; |
|
14 |
|
15 gBrowser.selectedTab = gBrowser.addTab(); |
|
16 |
|
17 gBrowser.loadURI("data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7"); |
|
18 |
|
19 registerCleanupFunction(function () { |
|
20 gBrowser.removeCurrentTab(); |
|
21 }); |
|
22 |
|
23 gBrowser.addEventListener("pageshow", function pageShown(event) { |
|
24 if (event.target.location == "about:blank") |
|
25 return; |
|
26 gBrowser.removeEventListener("pageshow", pageShown); |
|
27 |
|
28 executeSoon(function () { |
|
29 document.addEventListener("popupshown", contextMenuOpened); |
|
30 |
|
31 var img = gBrowser.contentDocument.getElementsByClassName("decoded")[0]; |
|
32 EventUtils.synthesizeMouseAtCenter(img, |
|
33 { type: "contextmenu", button: 2 }, |
|
34 gBrowser.contentWindow); |
|
35 }); |
|
36 }); |
|
37 |
|
38 function contextMenuOpened(event) { |
|
39 event.currentTarget.removeEventListener("popupshown", contextMenuOpened); |
|
40 |
|
41 MockFilePicker.showCallback = function(fp) { |
|
42 is(fp.defaultString, "index.gif"); |
|
43 executeSoon(finish); |
|
44 }; |
|
45 |
|
46 registerCleanupFunction(function () { |
|
47 MockFilePicker.cleanup(); |
|
48 }); |
|
49 |
|
50 // Select "Save Image As" option from context menu |
|
51 var saveImageAsCommand = document.getElementById("context-saveimage"); |
|
52 saveImageAsCommand.doCommand(); |
|
53 |
|
54 event.target.hidePopup(); |
|
55 } |
|
56 } |