1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/ipc/test-ipcbrowser-content.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function windowUtils() { 1.9 + return content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) 1.10 + .getInterface(Components.interfaces.nsIDOMWindowUtils); 1.11 +} 1.12 + 1.13 +function recvSetViewport(w, h) { 1.14 + 1.15 + dump("setting viewport to "+ w +"x"+ h +"\n"); 1.16 + 1.17 + windowUtils().setCSSViewport(w, h); 1.18 +} 1.19 + 1.20 +function recvSetDisplayPort(x, y, w, h) { 1.21 + 1.22 + dump("setting displayPort to <"+ x +", "+ y +", "+ w +", "+ h +">\n"); 1.23 + 1.24 + windowUtils().setDisplayPortForElement(x, y, w, h, content.document.documentElement, 0); 1.25 +} 1.26 + 1.27 +function recvSetResolution(xres, yres) { 1.28 + 1.29 + dump("setting xres="+ xres +" yres="+ yres +"\n"); 1.30 + 1.31 + windowUtils().setResolution(xres, yres); 1.32 +} 1.33 + 1.34 +function recvScrollBy(dx, dy) { 1.35 + content.scrollBy(dx, dy); 1.36 +} 1.37 + 1.38 +function recvScrollTo(x, y) { 1.39 + content.scrollTo(x, y); 1.40 +} 1.41 + 1.42 +addMessageListener( 1.43 + "setViewport", 1.44 + function (m) { recvSetViewport(m.json.w, m.json.h); } 1.45 +); 1.46 + 1.47 +addMessageListener( 1.48 + "setDisplayPort", 1.49 + function (m) { recvSetDisplayPort(m.json.x, m.json.y, 1.50 + m.json.w, m.json.h); } 1.51 +); 1.52 + 1.53 +addMessageListener( 1.54 + "setResolution", 1.55 + function (m) { recvSetResolution(m.json.xres, m.json.yres); } 1.56 +); 1.57 + 1.58 +addMessageListener( 1.59 + "scrollBy", 1.60 + function(m) { recvScrollBy(m.json.dx, m.json.dy); } 1.61 +); 1.62 + 1.63 +addMessageListener( 1.64 + "scrollTo", 1.65 + function(m) { recvScrollTo(m.json.x, m.json.y); } 1.66 +);