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: 'use strict';
michael@0:
michael@0: const { create } = require('sdk/frame/utils');
michael@0: const { open, close } = require('sdk/window/helpers');
michael@0:
michael@0: exports['test frame creation'] = function(assert, done) {
michael@0: open('data:text/html;charset=utf-8,Window').then(function (window) {
michael@0: let frame = create(window.document);
michael@0:
michael@0: assert.equal(frame.getAttribute('type'), 'content',
michael@0: 'frame type is content');
michael@0: assert.ok(frame.contentWindow, 'frame has contentWindow');
michael@0: assert.equal(frame.contentWindow.location.href, 'about:blank',
michael@0: 'by default "about:blank" is loaded');
michael@0: assert.equal(frame.docShell.allowAuth, false, 'auth disabled by default');
michael@0: assert.equal(frame.docShell.allowJavascript, false, 'js disabled by default');
michael@0: assert.equal(frame.docShell.allowPlugins, false,
michael@0: 'plugins disabled by default');
michael@0: close(window).then(done);
michael@0: });
michael@0: };
michael@0:
michael@0: exports['test fram has js disabled by default'] = function(assert, done) {
michael@0: open('data:text/html;charset=utf-8,window').then(function (window) {
michael@0: let frame = create(window.document, {
michael@0: uri: 'data:text/html;charset=utf-8,',
michael@0: });
michael@0: frame.contentWindow.addEventListener('DOMContentLoaded', function ready() {
michael@0: frame.contentWindow.removeEventListener('DOMContentLoaded', ready, false);
michael@0: assert.ok(!~frame.contentDocument.documentElement.innerHTML.indexOf('JS'),
michael@0: 'JS was executed');
michael@0:
michael@0: close(window).then(done);
michael@0: }, false);
michael@0: });
michael@0: };
michael@0:
michael@0: exports['test frame with js enabled'] = function(assert, done) {
michael@0: open('data:text/html;charset=utf-8,window').then(function (window) {
michael@0: let frame = create(window.document, {
michael@0: uri: 'data:text/html;charset=utf-8,',
michael@0: allowJavascript: true
michael@0: });
michael@0: frame.contentWindow.addEventListener('DOMContentLoaded', function ready() {
michael@0: frame.contentWindow.removeEventListener('DOMContentLoaded', ready, false);
michael@0: assert.ok(~frame.contentDocument.documentElement.innerHTML.indexOf('JS'),
michael@0: 'JS was executed');
michael@0:
michael@0: close(window).then(done);
michael@0: }, false);
michael@0: });
michael@0: };
michael@0:
michael@0: require('test').run(exports);