Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | "use strict"; |
michael@0 | 7 | |
michael@0 | 8 | const snappedSize = 330; |
michael@0 | 9 | const portraitSize = 900; |
michael@0 | 10 | const maxPortraitHeight = 900; |
michael@0 | 11 | |
michael@0 | 12 | function setSnappedViewstate() { |
michael@0 | 13 | ok(isLandscapeMode(), "setSnappedViewstate expects landscape mode to work."); |
michael@0 | 14 | |
michael@0 | 15 | let browser = Browser.selectedBrowser; |
michael@0 | 16 | |
michael@0 | 17 | // Reduce browser width to simulate small screen size. |
michael@0 | 18 | let fullWidth = browser.clientWidth; |
michael@0 | 19 | let padding = fullWidth - snappedSize; |
michael@0 | 20 | |
michael@0 | 21 | browser.style.borderRight = padding + "px solid gray"; |
michael@0 | 22 | |
michael@0 | 23 | // Communicate viewstate change |
michael@0 | 24 | ContentAreaObserver._updateViewState("snapped"); |
michael@0 | 25 | ContentAreaObserver._dispatchBrowserEvent("SizeChanged"); |
michael@0 | 26 | yield waitForMessage("Content:SetWindowSize:Complete", browser.messageManager); |
michael@0 | 27 | |
michael@0 | 28 | // Make sure it renders the new mode properly |
michael@0 | 29 | yield waitForMs(0); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function setPortraitViewstate() { |
michael@0 | 33 | ok(isLandscapeMode(), "setPortraitViewstate expects landscape mode to work."); |
michael@0 | 34 | |
michael@0 | 35 | let browser = Browser.selectedBrowser; |
michael@0 | 36 | |
michael@0 | 37 | let fullWidth = browser.clientWidth; |
michael@0 | 38 | let fullHeight = browser.clientHeight; |
michael@0 | 39 | let padding = fullWidth - portraitSize; |
michael@0 | 40 | |
michael@0 | 41 | browser.style.borderRight = padding + "px solid gray"; |
michael@0 | 42 | |
michael@0 | 43 | // cap the height to create more even surface for testing on |
michael@0 | 44 | if (fullHeight > maxPortraitHeight) |
michael@0 | 45 | browser.style.borderBottom = (fullHeight - maxPortraitHeight) + "px solid gray"; |
michael@0 | 46 | |
michael@0 | 47 | ContentAreaObserver._updateViewState("portrait"); |
michael@0 | 48 | ContentAreaObserver._dispatchBrowserEvent("SizeChanged"); |
michael@0 | 49 | yield waitForMessage("Content:SetWindowSize:Complete", browser.messageManager); |
michael@0 | 50 | |
michael@0 | 51 | // Make sure it renders the new mode properly |
michael@0 | 52 | yield waitForMs(0); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function restoreViewstate() { |
michael@0 | 56 | ContentAreaObserver._updateViewState("landscape"); |
michael@0 | 57 | ContentAreaObserver._dispatchBrowserEvent("SizeChanged"); |
michael@0 | 58 | yield waitForMessage("Content:SetWindowSize:Complete", Browser.selectedBrowser.messageManager); |
michael@0 | 59 | |
michael@0 | 60 | ok(isLandscapeMode(), "restoreViewstate should restore landscape mode."); |
michael@0 | 61 | |
michael@0 | 62 | Browser.selectedBrowser.style.removeProperty("border-right"); |
michael@0 | 63 | Browser.selectedBrowser.style.removeProperty("border-bottom"); |
michael@0 | 64 | |
michael@0 | 65 | yield waitForMs(0); |
michael@0 | 66 | } |