From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../browserElement_GetContentDimensions.js | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 dom/browser-element/mochitest/browserElement_GetContentDimensions.js (limited to 'dom/browser-element/mochitest/browserElement_GetContentDimensions.js') diff --git a/dom/browser-element/mochitest/browserElement_GetContentDimensions.js b/dom/browser-element/mochitest/browserElement_GetContentDimensions.js new file mode 100644 index 000000000..722c42b77 --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_GetContentDimensions.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Bug 757859 - Test the getContentDimensions functionality of mozbrowser + +"use strict"; +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); + +var resizeContent = function() { + var innerBox = content.document.getElementById('abox'); + innerBox.style.width = '800px'; + innerBox.style.height = '800px'; +} + +function runTest() { + + var iframe1 = document.createElement('iframe'); + iframe1.setAttribute('mozbrowser', 'true'); + + var iframeWidth = 400; + var iframeHeight = 400; + var numIframeLoaded = 0; + var numResizeEvents = 0; + var mm; + + iframe1.src = 'data:text/html,
test
'; + iframe1.style.width = iframeWidth + 'px'; + iframe1.style.height = iframeHeight + 'px'; + document.body.appendChild(iframe1); + + function iframeScrollAreaChanged(e) { + numResizeEvents++; + if (numResizeEvents === 1) { + ok(true, 'Resize event when changing content size'); + ok(e.detail.width > iframeWidth, 'Iframes content is larger than iframe'); + ok(e.detail.height > iframeHeight, 'Iframes content is larger than iframe'); + iframe1.src = 'data:text/html,
test
'; + } else if (numResizeEvents === 2) { + ok(true, 'Resize event when changing src'); + iframe1.removeEventListener('mozbrowserresize', iframeScrollAreaChanged); + SimpleTest.finish(); + } + } + + function iframeLoadedHandler() { + iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler); + mm = SpecialPowers.getBrowserFrameMessageManager(iframe1); + iframe1.getContentDimensions().onsuccess = function(e) { + ok(typeof e.target.result.width === 'number', 'Received width'); + ok(typeof e.target.result.height === 'number', 'Received height'); + ok(e.target.result.height <= iframeHeight, 'Iframes content is smaller than iframe'); + ok(e.target.result.width <= iframeWidth, 'Iframes content is smaller than iframe'); + iframe1.addEventListener('mozbrowserscrollareachanged', iframeScrollAreaChanged); + mm.loadFrameScript('data:,(' + resizeContent.toString() + ')();', false); + } + } + + iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler); +} + +addEventListener('load', function() { + SimpleTest.executeSoon(runTest); +}); -- cgit v1.2.3