gecko/dom/browser-element/mochitest/browserElement_SetVisibleFrames.js
Yoshi Huang 3e58618dde Bug 1196665 - Add originAttributes into SpecialPowers. r=bholley
From 7bb0fbba24f4f65d3fa83efe223b1431cd71fdb6 Mon Sep 17 00:00:00 2001
---
 dom/apps/tests/test_third_party_homescreen.html    |   8 +-
 .../test/test_messagemanager_assertpermission.html |   4 +-
 dom/base/test/test_messagemanager_targetchain.html |  16 +--
 ...rowserElement_AllowEmbedAppsInNestedOOIframe.js |  11 +-
 .../mochitest/browserElement_CopyPaste.js          |   9 +-
 .../browserElement_DisallowEmbedAppsInOOP.js       |   9 +-
 .../mochitest/browserElement_Proxy.js              |  10 +-
 .../browserElement_SetInputMethodActive.js         |   3 +-
 .../mochitest/browserElement_SetVisibleFrames.js   |  17 ++--
 .../mochitest/browserElement_SetVisibleFrames2.js  |  16 +--
 .../priority/test_ExpectingSystemMessage2.html     |  16 +--
 .../mochitest/priority/test_NestedFrames.html      |  16 +--
 dom/cache/test/mochitest/driver.js                 |  11 +-
 .../test/mochitest/test_cache_orphaned_body.html   |  33 +-----
 .../test/mochitest/test_cache_orphaned_cache.html  |  33 +-----
 dom/cache/test/mochitest/test_cache_restart.html   |  11 +-
 dom/cache/test/mochitest/test_cache_shrink.html    |  33 +-----
 dom/indexedDB/test/file.js                         |  12 +--
 dom/indexedDB/test/helpers.js                      |   9 +-
 dom/indexedDB/test/webapp_clearBrowserData.js      |   6 +-
 dom/inputmethod/mochitest/test_bug1043828.html     |   5 +-
 dom/inputmethod/mochitest/test_bug944397.html      |   5 +-
 .../mochitest/test_focus_blur_manage_events.html   |   5 +-
 .../mochitest/test_input_registry_events.html      |   5 +-
 .../mochitest/test_simple_manage_events.html       |   5 +-
 .../tests/test_permission_for_nested_oop_app.html  |   3 +-
 .../tests/test_permission_for_two_oop_apps.html    |   3 +-
 dom/ipc/tests/test_permission_helper.js            |  21 ++--
 .../test_permission_when_oop_app_crashes.html      |   3 +-
 dom/tv/test/mochitest/head.js                      |   5 +-
 .../test_SpecialPowersPushAppPermissions.html      |  14 ++-
 .../tests/Harness_sanity/test_bug816847.html       |   6 +-
 .../components/SpecialPowersObserver.js            |   4 +-
 .../content/SpecialPowersObserverAPI.js            |  24 +----
 testing/specialpowers/content/specialpowersAPI.js  | 111 ++++++++-------------
 35 files changed, 173 insertions(+), 329 deletions(-)
2015-10-07 14:35:43 +08:00

105 lines
3.5 KiB
JavaScript

/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 762939 - Test that visibility propagates down properly through
// hierarchies of <iframe mozbrowser>.
//
// In this test, we modify the parent's visibility and check that the child's
// visibility is changed as appopriate. We test modifying the child's
// visibility in a separate testcase.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
var iframe;
function runTest() {
var principal = SpecialPowers.wrap(document).nodePrincipal;
SpecialPowers.addPermission("browser", true, {url: SpecialPowers.wrap(principal.URI).spec,
originAttributes: {
appId: principal.appId,
inBrowser: true
}});
iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
// Our test involves three <iframe mozbrowser>'s, parent, child1, and child2.
// child1 and child2 are contained inside parent. child1 is visibile, and
// child2 is not.
//
// For the purposes of this test, we want there to be a process barrier
// between child{1,2} and parent. Therefore parent must be a non-remote
// <iframe mozbrowser>, until bug 761935 is resolved and we can have nested
// content processes.
iframe.remote = false;
iframe.addEventListener('mozbrowsershowmodalprompt', checkMessage);
expectMessage('parent:ready', test1);
document.body.appendChild(iframe);
iframe.src = 'file_browserElement_SetVisibleFrames_Outer.html';
}
function test1() {
expectMessage('child1:hidden', getVisibleTest1);
iframe.setVisible(false);
}
function getVisibleTest1() {
iframe.getVisible().onsuccess = function(evt) {
ok(evt.target.result === false, 'getVisible shows a hidden frame');
test2();
};
}
function test2() {
expectMessage('child1:visible', getVisibleTest2);
iframe.setVisible(true);
}
function getVisibleTest2() {
iframe.getVisible().onsuccess = function(evt) {
ok(evt.target.result === true, 'getVisible shows a displayed frame');
finish();
};
}
function finish() {
// We need to remove this listener because when this test finishes and the
// iframe containing this document is navigated, we'll fire a
// visibilitychange(false) event on all child iframes. That's OK and
// expected, but if we don't remove our listener, then we'll end up causing
// the /next/ test to fail!
iframe.removeEventListener('mozbrowsershowmodalprompt', checkMessage);
var principal = SpecialPowers.wrap(document).nodePrincipal;
SpecialPowers.removePermission("browser", {url: SpecialPowers.wrap(principal.URI).spec,
originAttributes: {
appId: principal.appId,
inBrowser: true
}});
SimpleTest.finish();
}
var expectedMsg = null;
var expectedMsgCallback = null;
function expectMessage(msg, next) {
expectedMsg = msg;
expectedMsgCallback = next;
}
function checkMessage(e) {
var msg = e.detail.message;
is(msg, expectedMsg);
if (msg == expectedMsg) {
expectedMsg = null;
SimpleTest.executeSoon(function() { expectedMsgCallback() });
}
}
addEventListener('testready', runTest);