Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1114800 - Don't let the app element and the app iframe size get o…
Browse files Browse the repository at this point in the history
…ut of sync. r=alive
  • Loading branch information
etiennesegonzac committed Jan 6, 2015
1 parent a14de2c commit a1d2ad6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
20 changes: 12 additions & 8 deletions apps/system/js/app_window.js
Expand Up @@ -846,15 +846,16 @@
this.lockOrientation();
}
}
// Resize only the overlays not the app
var width = layoutManager.width;
var height = layoutManager.getHeightFor(this);

// We don't want to resize/reflow all backgrounds app
// so we make sure the iframe doesn't get resized
if (this.browser) {
this.iframe.style.width = this.width + 'px';
this.iframe.style.height = this.height + 'px';
}

var width = layoutManager.width;
var height = layoutManager.getHeightFor(this);
this.element.style.width = width + 'px';
this.element.style.height = height + 'px';

Expand Down Expand Up @@ -1231,6 +1232,10 @@
*/
AppWindow.prototype._hideScreenshotOverlay =
function aw__hideScreenshotOverlay() {
// The iframe might be "freezed" to an old size
// making sure it's resized properly before dipslaying it
this.iframe.style.width = '';
this.iframe.style.height = '';

if (!this.screenshotOverlay ||
!this.screenshotOverlay.classList.contains('visible')) {
Expand Down Expand Up @@ -1452,12 +1457,11 @@

this.width = width;
this.height = height;
this.element.style.width = this.width + 'px';
this.element.style.height = this.height + 'px';

this.element.style.width = width + 'px';
this.element.style.height = height + 'px';

this.reviveBrowser();
this.iframe.style.width = '';
this.iframe.style.height = '';

this.resized = true;
if (this.screenshotOverlay) {
Expand All @@ -1474,7 +1478,7 @@
* @event AppWindow#appresize
*/
this.publish('resize');
this.debug('W:', this.width, 'H:', this.height);
this.debug('W:', width, 'H:', height);
};

/**
Expand Down
21 changes: 11 additions & 10 deletions apps/system/test/unit/app_window_test.js
Expand Up @@ -265,16 +265,6 @@ suite('system/AppWindow', function() {
assert.equal(app1.screenshotOverlay.style.visibility, '');
});

test('Reset the iframe inline size', function() {
app1.iframe.style.width = '480px';
app1.iframe.style.height = '320px';
var stubIsActive = this.sinon.stub(app1, 'isActive');
stubIsActive.returns(true);
app1.resize();
assert.equal(app1.iframe.style.width, '');
assert.equal(app1.iframe.style.height, '');
});

test('No navigation setting in manifest', function() {
var spy = this.sinon.spy(window, 'AppChrome');
new AppWindow(fakeChromeConfigWithoutNavigation); // jshint ignore:line
Expand Down Expand Up @@ -691,6 +681,17 @@ suite('system/AppWindow', function() {
assert.isFalse(app1.element.classList.contains('overlay'));
});

test('should reset the iframe inline size when hiding the overlay',
function() {
app1.iframe.style.width = '480px';
app1.iframe.style.height = '320px';

app1._hideScreenshotOverlay();

assert.equal(app1.iframe.style.width, '');
assert.equal(app1.iframe.style.height, '');
});

test('hideScreenshotOverlay noop when the screenshot is not displayed',
function() {
app1._screenshotOverlayState = 'none';
Expand Down

0 comments on commit a1d2ad6

Please sign in to comment.