'use strict';
const promiseSleep = require('./promise').sleep;
const { getHiddenWindow } = require('sdk/window/utils');
let hiddenWindow = null;
module.exports = {
get window() {
if (!hiddenWindow) {
try {
let win = getHiddenWindow();
if (win.document.readyState === 'complete' && win.document.documentElement.appendChild) {
hiddenWindow = win;
}
} catch (e) {}
}
return hiddenWindow;
},
getFrame: function (props = {}) {
if (typeof props.url === 'undefined') {
const randomId = Date.now() + Math.floor(Math.random() * 1000000);
switch (props.contentType) {
case 'xul':
props.url = 'data:application/vnd.mozilla.xul+xml;charset=utf-8,' + encodeURIComponent(`