diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/browser-element/mochitest/browserElement_Viewmode.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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_Viewmode.js')
-rw-r--r-- | dom/browser-element/mochitest/browserElement_Viewmode.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/browserElement_Viewmode.js b/dom/browser-element/mochitest/browserElement_Viewmode.js new file mode 100644 index 000000000..51627d9a8 --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_Viewmode.js @@ -0,0 +1,71 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that the onmozbrowsermetachange event for viewmode works. +"use strict"; + +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); +browserElementTestHelpers.addPermission(); + +function runTest() { + function loadFrameScript(script) { + SpecialPowers.getBrowserFrameMessageManager(iframe1) + .loadFrameScript('data:,' + script, + /* allowDelayedLoad = */ false); + } + + let iframe1 = document.createElement('iframe'); + iframe1.setAttribute('mozbrowser', 'true'); + iframe1.src = "http://test/tests/dom/browser-element/mochitest/file_browserElement_Viewmode.html"; + iframe1.addEventListener('mozbrowsermetachange', tests); + document.body.appendChild(iframe1); + + let numMetaChanges = 0; + function tests(e) { + let detail = e.detail; + + switch (numMetaChanges++) { + case 0: { + is(detail.name, 'viewmode', 'name matches'); + is(detail.content, 'projection=stereo', 'content matches'); + is(detail.type, 'added', 'type matches'); + + let script = + "var meta = content.document.head.querySelector('meta');" + + "meta.content = 'projection=mono';"; + loadFrameScript(script); + break; + } + + case 1: { + is(detail.name, 'viewmode', 'name matches'); + is(detail.content, 'projection=mono', 'content matches'); + is(detail.type, 'changed', 'type matches'); + + let script = + "var meta = content.document.head.querySelector('meta');" + + "meta.parentNode.removeChild(meta);"; + loadFrameScript(script); + break; + } + + case 2: { + is(detail.name, 'viewmode', 'name matches'); + is(detail.content, 'projection=mono', 'content matches'); + is(detail.type, 'removed', 'type matches'); + + SimpleTest.finish(); + break; + } + + default: { + ok(false, 'Too many metachange events.'); + break; + } + } + }; +} + +window.addEventListener('testready', runTest); + |