michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let modifiers = { michael@0: accelKey: true michael@0: }; michael@0: michael@0: let toolbox; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: addTab("about:blank", function() { michael@0: openToolbox(); michael@0: }); michael@0: } michael@0: michael@0: function openToolbox() { michael@0: let target = TargetFactory.forTab(gBrowser.selectedTab); michael@0: michael@0: gDevTools.showToolbox(target).then((aToolbox) => { michael@0: toolbox = aToolbox; michael@0: toolbox.selectTool("styleeditor").then(testZoom); michael@0: }); michael@0: } michael@0: michael@0: function testZoom() { michael@0: info("testing zoom keys"); michael@0: michael@0: testZoomLevel("in", 2, 1.2); michael@0: testZoomLevel("out", 3, 0.9); michael@0: testZoomLevel("reset", 1, 1); michael@0: michael@0: tidyUp(); michael@0: } michael@0: michael@0: function testZoomLevel(type, times, expected) { michael@0: sendZoomKey("toolbox-zoom-"+ type + "-key", times); michael@0: michael@0: let zoom = getCurrentZoom(toolbox); michael@0: is(zoom.toFixed(2), expected, "zoom level correct after zoom " + type); michael@0: michael@0: is(toolbox.zoomValue.toFixed(2), expected, michael@0: "saved zoom level is correct after zoom " + type); michael@0: } michael@0: michael@0: function sendZoomKey(id, times) { michael@0: let key = toolbox.doc.getElementById(id).getAttribute("key"); michael@0: for (let i = 0; i < times; i++) { michael@0: EventUtils.synthesizeKey(key, modifiers, toolbox.doc.defaultView); michael@0: } michael@0: } michael@0: michael@0: function getCurrentZoom() { michael@0: var contViewer = toolbox.frame.docShell.contentViewer; michael@0: var docViewer = contViewer.QueryInterface(Ci.nsIMarkupDocumentViewer); michael@0: return docViewer.fullZoom; michael@0: } michael@0: michael@0: function tidyUp() { michael@0: toolbox.destroy().then(function() { michael@0: gBrowser.removeCurrentTab(); michael@0: michael@0: toolbox = modifiers = null; michael@0: finish(); michael@0: }); michael@0: }