GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit c782a4e0 authored by boklm's avatar boklm
Browse files

Convert the noscript test to marionette

parent 741c3880
......@@ -345,7 +345,7 @@ our @tests = (
},
{
name => 'noscript',
type => 'mozmill',
type => 'marionette',
descr => 'Check that noscript options are working',
use_net => 1,
prefs => {
......
# https://trac.torproject.org/projects/tor/ticket/13053
from marionette_driver import By
from marionette_driver.errors import MarionetteException, NoSuchElementException
from firefox_ui_harness import FirefoxTestCase
import testsuite
class Test(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
ts = testsuite.TestSuite()
self.ts = ts
self.http_url = "%s/noscript/" % ts.t['options']['test_data_url']
self.https_url = "%s/noscript/" % ts.t['options']['test_data_url_https']
def test_noscript(self):
self.assertEqual(self.prefs.get_pref('noscript.global'), False,
msg="pref noscript.global is not false")
self.assertEqual(self.prefs.get_pref('noscript.globalHttpsWhitelist'), True,
msg="pref noscript.globalHttpsWhitelist is not true")
self.assertEqual(self.prefs.get_pref('noscript.cascadePermissions'), True,
msg="pref noscript.cascadePermissions is not true")
self.marionette.set_search_timeout(1000)
with self.marionette.using_context('content'):
# http page sourcing http js
self.marionette.navigate("%s/http_src.html" % self.http_url)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="http page sourcing http js")
# https page sourcing http js
self.marionette.navigate("%s/http_src.html" % self.https_url)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="https page sourcing http js")
# https page sourcing http js (alternate hostname)
self.marionette.navigate("%s/alternate_http_src.html" % self.https_url)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="https page sourcing http js (alternate hostname)")
# http page sourcing https js
self.marionette.navigate("%s/https_src.html" % self.http_url)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="http page sourcing https js")
# https page sourcing https js
self.marionette.navigate("%s/https_src.html" % self.https_url)
res = True
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = False
self.assertTrue(res, msg="https page sourcing https js")
self.assertEqual('JavaScriptEnabled', elt.text, msg="https page sourcing https js")
# https page sourcing https js (alternate hostname)
self.marionette.navigate("%s/alternate_https_src.html" % self.https_url)
res = True
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = False
self.assertTrue(res, msg="https page sourcing https js (alternate hostname)")
self.assertEqual('JavaScriptEnabled', elt.text,
msg="https page sourcing https js (alternate hostname)")
# http page with http iframe
self.marionette.navigate("%s/http_iframe.html" % self.http_url)
iframe = self.marionette.find_element('id', 'iframe')
self.marionette.switch_to_frame(iframe)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="http page with http iframe")
self.marionette.switch_to_default_content()
# http page with https iframe
self.marionette.navigate("%s/https_iframe.html" % self.http_url)
iframe = self.marionette.find_element('id', 'iframe')
self.marionette.switch_to_frame(iframe)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="http page with https iframe")
self.marionette.switch_to_default_content()
# https page with http iframe
self.marionette.navigate("%s/http_iframe.html" % self.https_url)
iframe = self.marionette.find_element('id', 'iframe')
self.marionette.switch_to_frame(iframe)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="https page with http iframe")
self.marionette.switch_to_default_content()
# https page sourcing https js (alternate hostname)
self.marionette.navigate("%s/alternate_http_iframe.html" % self.https_url)
iframe = self.marionette.find_element('id', 'iframe')
self.marionette.switch_to_frame(iframe)
res = False
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = True
self.assertTrue(res, msg="https page sourcing https js (alternate hostname)")
self.marionette.switch_to_default_content()
# https page with https iframe
self.marionette.navigate("%s/https_iframe.html" % self.https_url)
iframe = self.marionette.find_element('id', 'iframe')
self.marionette.switch_to_frame(iframe)
res = True
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = False
self.assertTrue(res, msg="https page with https iframe")
self.assertEqual(elt.text, 'JavaScriptEnabled',
msg="https page with https iframe")
self.marionette.switch_to_default_content()
# https page with https iframe (alternate hostname)
self.marionette.navigate("%s/alternate_https_iframe.html" % self.https_url)
iframe = self.marionette.find_element('id', 'iframe')
self.marionette.switch_to_frame(iframe)
res = True
try:
elt = self.marionette.find_element('id', 'test_result')
except NoSuchElementException:
res = False
self.assertTrue(res, msg="https page with https iframe")
self.assertEqual(elt.text, 'JavaScriptEnabled',
msg="https page with https iframe")
self.marionette.switch_to_default_content()
// https://trac.torproject.org/projects/tor/ticket/13053
"use strict";
var {expect} = require("../mozilla-mozmill-tests/lib/assertions");
var prefs = require("../mozilla-mozmill-tests/firefox/lib/prefs");
var testsuite = require("../lib/testsuite");
var setupModule = function(aModule) {
aModule.controller = mozmill.getBrowserController();
}
var testNoscript = function () {
var http_url = testsuite.options.test_data_url + '/noscript/';
var https_url = testsuite.options.test_data_url_https + '/noscript/';
var prefSrv = prefs.preferences;
var noscript_global = prefSrv.getPref('noscript.global', true);
expect.equal(noscript_global, false, 'noscript.global');
var noscript_httpswhitelist = prefSrv.getPref('noscript.globalHttpsWhitelist', false);
expect.equal(noscript_httpswhitelist, true, 'noscript.globalHttpsWhitelist');
var noscript_cascade = prefSrv.getPref('noscript.cascadePermissions', false);
expect.equal(noscript_cascade, true, 'noscript.cascadePermissions');
// http page sourcing http js
controller.open(http_url + 'http_src.html');
controller.waitForPageLoad();
controller.sleep(1000);
var f = new elementslib.ID(controller.window.document, "test_result");
expect.equal(null, f.getNode(), 'http src in http page');
// https page sourcing http js
controller.open(https_url + 'http_src.html');
controller.waitForPageLoad();
controller.sleep(1000);
var f = new elementslib.ID(controller.window.document, "test_result");
expect.equal(null, f.getNode(), 'http src in https page');
// https page sourcing http js (alternate hostname)
controller.open(https_url + 'alternate_http_src.html');
controller.waitForPageLoad();
controller.sleep(1000);
var f = new elementslib.ID(controller.window.document, "test_result");
expect.equal(null, f.getNode(), 'http src in https page (alternate hostname)');
// http page sourcing https js
controller.open(http_url + 'https_src.html');
controller.waitForPageLoad();
controller.sleep(1000);
var f = new elementslib.ID(controller.window.document, "test_result");
expect.equal(null, f.getNode(), 'https src in http page');
// https page sourcing https js
controller.open(https_url + 'https_src.html');
controller.waitForPageLoad();
controller.sleep(1000);
var f = new elementslib.ID(controller.window.document, "test_result");
if (f.getNode() == null)
expect.fail('https src in https page');
else
expect.equal('JavaScriptEnabled', f.getNode().innerHTML, 'https src in https page');
// https page sourcing https js (alternate hostname)
controller.open(https_url + 'alternate_https_src.html');
controller.waitForPageLoad();
controller.sleep(1000);
var f = new elementslib.ID(controller.window.document, "test_result");
if (f.getNode() == null)
expect.fail('https src in https page (alternate hostname)');
else
expect.equal('JavaScriptEnabled', f.getNode().innerHTML, 'https src in https page (alternate hostname)');
// http page with http iframe
controller.open(http_url + 'http_iframe.html');
controller.waitForPageLoad();
controller.sleep(1000);
var frame = new elementslib.Selector(controller.window.document, "#iframe");
var frameWindow = frame.getNode().contentWindow;
var f = frameWindow.document.getElementById("test_result");
expect.equal(null, f, 'http iframe in http page');
// http page with https iframe
controller.open(http_url + 'https_iframe.html');
controller.waitForPageLoad();
controller.sleep(1000);
var frame = new elementslib.Selector(controller.window.document, "#iframe");
var frameWindow = frame.getNode().contentWindow;
var f = frameWindow.document.getElementById("test_result");
expect.equal(null, f, 'https iframe in http page');
// https page with http iframe
controller.open(https_url + 'http_iframe.html');
controller.waitForPageLoad();
controller.sleep(1000);
var frame = new elementslib.Selector(controller.window.document, "#iframe");
var frameWindow = frame.getNode().contentWindow;
var f = frameWindow.document.getElementById("test_result");
expect.equal(null, f, 'http iframe in https page');
// https page with http iframe (alternate hostname)
controller.open(https_url + 'alternate_http_iframe.html');
controller.waitForPageLoad();
controller.sleep(1000);
var frame = new elementslib.Selector(controller.window.document, "#iframe");
var frameWindow = frame.getNode().contentWindow;
var f = frameWindow.document.getElementById("test_result");
expect.equal(null, f, 'http iframe in https page (alternate hostname)');
// https page with https iframe
controller.open(https_url + 'https_iframe.html');
controller.waitForPageLoad();
controller.sleep(1000);
var frame = new elementslib.Selector(controller.window.document, "#iframe");
var frameWindow = frame.getNode().contentWindow;
var f = frameWindow.document.getElementById("test_result");
if (f == null)
expect.fail('https iframe in https page');
else
expect.equal('JavaScriptEnabled', f.innerHTML, 'https iframe in https page');
// https page with https iframe (alternate hostname)
controller.open(https_url + 'alternate_https_iframe.html');
controller.waitForPageLoad();
controller.sleep(1000);
var frame = new elementslib.Selector(controller.window.document, "#iframe");
var frameWindow = frame.getNode().contentWindow;
var f = frameWindow.document.getElementById("test_result");
if (f == null)
expect.fail('https iframe in https page (alternate hostname)');
else
expect.equal('JavaScriptEnabled', f.innerHTML, 'https iframe in https page (alternate hostname)');
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment