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 8a54684b authored by boklm's avatar boklm
Browse files

Convert the resource-timing test to marionette

parent c7bb99cd
......@@ -318,9 +318,14 @@ our @tests = (
},
{
name => 'resource-timing',
type => 'mozmill',
type => 'marionette',
descr => 'Check that the Resource Timing API is really disabled',
use_net => 1,
# To check that the test fails when resource timing is enabled,
# uncomment this:
#prefs => {
# 'dom.enable_resource_timing' => 'true',
#},
},
{
name => 'searchengines',
......
# This test checks whether the Resource Timing API (see:
# http://www.w3.org/TR/resource-timing/) is really disabled in the default
# Tor Browser. Setting |dom.enable_resource_timing| to |false| and testing that
# might not be sufficient.
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
class Test(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
self.TEST_URL = "https://www.mediawiki.org/wiki/MediaWiki"
self.RESOURCE_URL = "https://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png"
def test_resource_timing(self):
with self.marionette.using_context('content'):
self.marionette.navigate(self.TEST_URL)
# If resource timing is disabled we should not be able to get resource
# entries at all in the first place. We test all three methods for safety's
# sake.
# getEntriesByType()
err_msg = 'resource entries found (getEntriesByType())'
self.assertTrue(self.marionette.execute_script("""
var pass = false;
try {
let resources = document.defaultView.performance.
getEntriesByType("resource")[0];
} catch (e) {
pass = true;
}
return pass;
"""),
msg=err_msg)
# getEntriesByName()
err_msg = "resource entries found (getEntriesByName())"
self.assertTrue(self.marionette.execute_script("""
var pass = false;
try {
let resources = document.defaultView.performance.
getEntriesByName(arguments[0])[0];
} catch (e) {
pass = true;
}
return pass;
""", script_args=[self.RESOURCE_URL]),
msg=err_msg)
# getEntries()
err_msg = "resource entries found (getEntries())"
self.assertTrue(self.marionette.execute_script("""
var pass = false;
try {
let resources = document.defaultView.performance.
getEntries()[0];
} catch (e) {
pass = true;
}
return pass;
"""),
msg=err_msg)
// This test checks whether the Resource Timing API (see:
// http://www.w3.org/TR/resource-timing/) is really disabled in the default
// Tor Browser. Setting |dom.enable_resource_timing| to |false| and testing that
// might not be sufficient.
"use strict";
var {expect} = require("../mozilla-mozmill-tests/lib/assertions");
var common = require("../lib/common");
const TEST_URL = "https://www.mediawiki.org/wiki/MediaWiki";
const RESOURCE_URL =
"https://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png";
var setupModule = function(aModule) {
aModule.controller = mozmill.getBrowserController();
}
var testNavigationTiming = function() {
var pass = false;
common.load_page(controller, TEST_URL);
// If resource timing is disabled we should not be able to get resource
// entries at all in the first place. We test all three methods for safety's
// sake.
// getEntriesByType()
try {
let resources = controller.tabs.activeTab.defaultView.performance.
getEntriesByType("resource")[0];
} catch (e) {
pass = true;
}
expect.ok(pass, "No resource entries found (getEntriesByType())");
// getEntriesByName()
pass = false;
try {
let resources = controller.tabs.activeTab.defaultView.performance.
getEntriesByName(RESOURCE_URL)[0];
} catch (e) {
pass = true;
}
expect.ok(pass, "No resource entries found (getEntriesByName())");
// getEntries()
pass = false;
try {
let resources = controller.tabs.activeTab.defaultView.performance.
getEntries()[0];
} catch (e) {
pass = true;
}
expect.ok(pass, "No resource entries found (getEntries())");
}
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