michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: var MockFilePicker = SpecialPowers.MockFilePicker; michael@0: MockFilePicker.init(window); michael@0: michael@0: /** michael@0: * TestCase for bug 564387 michael@0: * michael@0: */ michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: var fileName; michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: michael@0: gBrowser.loadURI("data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7"); michael@0: michael@0: registerCleanupFunction(function () { michael@0: gBrowser.removeCurrentTab(); michael@0: }); michael@0: michael@0: gBrowser.addEventListener("pageshow", function pageShown(event) { michael@0: if (event.target.location == "about:blank") michael@0: return; michael@0: gBrowser.removeEventListener("pageshow", pageShown); michael@0: michael@0: executeSoon(function () { michael@0: document.addEventListener("popupshown", contextMenuOpened); michael@0: michael@0: var img = gBrowser.contentDocument.getElementsByClassName("decoded")[0]; michael@0: EventUtils.synthesizeMouseAtCenter(img, michael@0: { type: "contextmenu", button: 2 }, michael@0: gBrowser.contentWindow); michael@0: }); michael@0: }); michael@0: michael@0: function contextMenuOpened(event) { michael@0: event.currentTarget.removeEventListener("popupshown", contextMenuOpened); michael@0: michael@0: MockFilePicker.showCallback = function(fp) { michael@0: is(fp.defaultString, "index.gif"); michael@0: executeSoon(finish); michael@0: }; michael@0: michael@0: registerCleanupFunction(function () { michael@0: MockFilePicker.cleanup(); michael@0: }); michael@0: michael@0: // Select "Save Image As" option from context menu michael@0: var saveImageAsCommand = document.getElementById("context-saveimage"); michael@0: saveImageAsCommand.doCommand(); michael@0: michael@0: event.target.hidePopup(); michael@0: } michael@0: }