michael@0: // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const snappedSize = 330; michael@0: const portraitSize = 900; michael@0: const maxPortraitHeight = 900; michael@0: michael@0: function setSnappedViewstate() { michael@0: ok(isLandscapeMode(), "setSnappedViewstate expects landscape mode to work."); michael@0: michael@0: let browser = Browser.selectedBrowser; michael@0: michael@0: // Reduce browser width to simulate small screen size. michael@0: let fullWidth = browser.clientWidth; michael@0: let padding = fullWidth - snappedSize; michael@0: michael@0: browser.style.borderRight = padding + "px solid gray"; michael@0: michael@0: // Communicate viewstate change michael@0: ContentAreaObserver._updateViewState("snapped"); michael@0: ContentAreaObserver._dispatchBrowserEvent("SizeChanged"); michael@0: yield waitForMessage("Content:SetWindowSize:Complete", browser.messageManager); michael@0: michael@0: // Make sure it renders the new mode properly michael@0: yield waitForMs(0); michael@0: } michael@0: michael@0: function setPortraitViewstate() { michael@0: ok(isLandscapeMode(), "setPortraitViewstate expects landscape mode to work."); michael@0: michael@0: let browser = Browser.selectedBrowser; michael@0: michael@0: let fullWidth = browser.clientWidth; michael@0: let fullHeight = browser.clientHeight; michael@0: let padding = fullWidth - portraitSize; michael@0: michael@0: browser.style.borderRight = padding + "px solid gray"; michael@0: michael@0: // cap the height to create more even surface for testing on michael@0: if (fullHeight > maxPortraitHeight) michael@0: browser.style.borderBottom = (fullHeight - maxPortraitHeight) + "px solid gray"; michael@0: michael@0: ContentAreaObserver._updateViewState("portrait"); michael@0: ContentAreaObserver._dispatchBrowserEvent("SizeChanged"); michael@0: yield waitForMessage("Content:SetWindowSize:Complete", browser.messageManager); michael@0: michael@0: // Make sure it renders the new mode properly michael@0: yield waitForMs(0); michael@0: } michael@0: michael@0: function restoreViewstate() { michael@0: ContentAreaObserver._updateViewState("landscape"); michael@0: ContentAreaObserver._dispatchBrowserEvent("SizeChanged"); michael@0: yield waitForMessage("Content:SetWindowSize:Complete", Browser.selectedBrowser.messageManager); michael@0: michael@0: ok(isLandscapeMode(), "restoreViewstate should restore landscape mode."); michael@0: michael@0: Browser.selectedBrowser.style.removeProperty("border-right"); michael@0: Browser.selectedBrowser.style.removeProperty("border-bottom"); michael@0: michael@0: yield waitForMs(0); michael@0: }