Bug 595068 - Add a cheat code to generate fake multitouch zoom events [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 09 Sep 2010 21:59:30 -0700
changeset 66643 62fbd8300803fc6c2eb41486c3cf79dc79507fdf
parent 66642 fd25fd4891b66da9f62f7a6a20cedfc84ccb49ea
child 66644 a9515c975d686b0c7476eede0ccaf87185646bc4
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs595068
Bug 595068 - Add a cheat code to generate fake multitouch zoom events [r=mfinkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -89,17 +89,17 @@ function onDebugKeyPress(ev) {
   const h = 72;
   const i = 73;
   const j = 74;
   const k = 75;
   const l = 76;
   const m = 77;
   const n = 78;
   const o = 79;
-  const p = 80;
+  const p = 80;  // fake pinch zoom
   const q = 81;  // toggle orientation
   const r = 82;
   const s = 83;
   const t = 84;
   const u = 85;
   const v = 86;
   const w = 87;
   const x = 88;
@@ -107,16 +107,35 @@ function onDebugKeyPress(ev) {
   const z = 90;
 
   switch (ev.charCode) {
   case f:
     MemoryObserver.observe();
     dump("Forced a GC\n");
     break;
 #ifndef MOZ_PLATFORM_MAEMO
+  case p:
+    function dispatchMagnifyEvent(aName, aDelta) {
+      let e = document.createEvent("SimpleGestureEvent");
+      e.initSimpleGestureEvent("MozMagnifyGesture"+aName, true, true, window, null,
+                               0, 0, 0, 0, false, false, false, false, 0, null, 0, aDelta);
+      document.getElementById("inputhandler-overlay").dispatchEvent(e);
+    }
+    dispatchMagnifyEvent("Start", 0);
+
+    let frame = 0;
+    let timer = new Util.Timeout();
+    timer.interval(100, function() {
+      dispatchMagnifyEvent("Update", 20);
+      if (++frame > 10) {
+        timer.clear();
+        dispatchMagnifyEvent("", frame*20);
+      }
+    });
+    break;
   case q:
     if (Util.isPortrait())
       window.top.resizeTo(800,480);
     else
       window.top.resizeTo(480,800);
     break;
 #endif
   default: