summaryrefslogtreecommitdiffstats
path: root/dom/browser-element/mochitest/browserElement_GetContentDimensions.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/browser-element/mochitest/browserElement_GetContentDimensions.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/browser-element/mochitest/browserElement_GetContentDimensions.js')
-rw-r--r--dom/browser-element/mochitest/browserElement_GetContentDimensions.js66
1 files changed, 66 insertions, 0 deletions
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,<html><body><div id=\'abox\' ' +
+ 'style=\'background:blue;width:200px;height:200px\'>test</div></body></html>';
+ 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,<html><body><div id=\'abox\' ' +
+ 'style=\'background:blue;width:200px;height:200px\'>test</div></body></html>';
+ } 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);
+});