Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/.eslintignore b/.eslintignore
- --- a/.eslintignore
- +++ b/.eslintignore
- @@ -216,7 +216,6 @@ dom/security/test/csp/**
- dom/security/test/general/**
- dom/security/test/mixedcontentblocker/**
- dom/security/test/sri/**
- -dom/security/test/unit/**
- dom/serviceworkers/**
- dom/smil/**
- dom/svg/**
- diff --git a/dom/security/test/unit/test_csp_reports.js b/dom/security/test/unit/test_csp_reports.js
- --- a/dom/security/test/unit/test_csp_reports.js
- +++ b/dom/security/test/unit/test_csp_reports.js
- @@ -2,7 +2,7 @@
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- -ChromeUtils.import('resource://gre/modules/NetUtil.jsm');
- +ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
- ChromeUtils.import("resource://gre/modules/Services.jsm");
- ChromeUtils.import("resource://testing-common/httpd.js");
- @@ -33,7 +33,7 @@ function makeReportHandler(testpath, mes
- ? request.getHeader("Content-Type") : undefined;
- if (contentType !== "application/csp-report") {
- do_throw("violation report should have the 'application/csp-report' " +
- - "content-type, when in fact it is " + contentType.toString())
- + "content-type, when in fact it is " + contentType.toString());
- }
- // obtain violation report
- @@ -47,7 +47,7 @@ function makeReportHandler(testpath, mes
- // dump("EXPECTED: \n" + JSON.stringify(expectedJSON) + "\n\n");
- for (var i in expectedJSON)
- - Assert.equal(expectedJSON[i], reportObj['csp-report'][i]);
- + Assert.equal(expectedJSON[i], reportObj["csp-report"][i]);
- testsToFinish--;
- httpServer.registerPathHandler(testpath, null);
- @@ -80,9 +80,8 @@ function makeTest(id, expectedJSON, useR
- dump("Created test " + id + " : " + policy + "\n\n");
- - let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
- - .getService(Ci.nsIScriptSecurityManager);
- - principal = ssm.createCodebasePrincipal(selfuri, {});
- +
- + principal = Services.scriptSecurityManager.createCodebasePrincipal(selfuri, {});
- csp.setRequestContext(null, principal);
- // Load up the policy
- @@ -93,7 +92,7 @@ function makeTest(id, expectedJSON, useR
- var handler = makeReportHandler("/test" + id, "Test " + id, expectedJSON);
- httpServer.registerPathHandler("/test" + id, handler);
- - //trigger the violation
- + // trigger the violation
- callback(csp);
- }
- @@ -122,11 +121,11 @@ function run_test() {
- // test that eval violations cause a report.
- makeTest(1, {"blocked-uri": "eval",
- // JSON script-sample is UTF8 encoded
- - "script-sample" : "\xc2\xa3\xc2\xa5\xc2\xb5\xe5\x8c\x97\xf0\xa0\x9d\xb9",
- + "script-sample": "\xc2\xa3\xc2\xa5\xc2\xb5\xe5\x8c\x97\xf0\xa0\x9d\xb9",
- "line-number": 1,
- "column-number": 2}, false,
- function(csp) {
- - let evalOK = true, oReportViolation = {'value': false};
- + let evalOK = true, oReportViolation = {"value": false};
- evalOK = csp.getAllowsEval(oReportViolation);
- // this is not a report only policy, so it better block eval
- @@ -178,7 +177,7 @@ function run_test() {
- // test that eval violations cause a report in report-only policy
- makeTest(4, {"blocked-uri": "inline"}, true,
- function(csp) {
- - let evalOK = true, oReportViolation = {'value': false};
- + let evalOK = true, oReportViolation = {"value": false};
- evalOK = csp.getAllowsEval(oReportViolation);
- // this is a report only policy, so it better allow eval
- @@ -225,7 +224,6 @@ function run_test() {
- var selfSpec = REPORT_SERVER_URI + ":" + REPORT_SERVER_PORT + "/foo/self/foo.js";
- makeTest(7, {"blocked-uri": selfSpec}, false,
- function(csp) {
- - var uri = NetUtil
- // shouldLoad creates and sends out the report here.
- csp.shouldLoad(Ci.nsIContentPolicy.TYPE_SCRIPT,
- null, // nsICSPEventListener
- diff --git a/dom/security/test/unit/test_csp_upgrade_insecure_request_header.js b/dom/security/test/unit/test_csp_upgrade_insecure_request_header.js
- --- a/dom/security/test/unit/test_csp_upgrade_insecure_request_header.js
- +++ b/dom/security/test/unit/test_csp_upgrade_insecure_request_header.js
- @@ -1,14 +1,12 @@
- ChromeUtils.import("resource://testing-common/httpd.js");
- ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
- ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
- -
- -var prefs = Cc["@mozilla.org/preferences-service;1"].
- - getService(Ci.nsIPrefBranch);
- +ChromeUtils.import("resource://gre/modules/Services.jsm");
- // Since this test creates a TYPE_DOCUMENT channel via javascript, it will
- // end up using the wrong LoadInfo constructor. Setting this pref will disable
- // the ContentPolicyType assertion in the constructor.
- -prefs.setBoolPref("network.loadinfo.skip_type_assertion", true);
- +Services.prefs.setBoolPref("network.loadinfo.skip_type_assertion", true);
- XPCOMUtils.defineLazyGetter(this, "URL", function() {
- return "http://localhost:" + httpserver.identity.primaryPort;
- @@ -23,22 +21,22 @@ var tests = [
- {
- description: "should not set request header for TYPE_OTHER",
- expectingHeader: false,
- - contentType: Ci.nsIContentPolicy.TYPE_OTHER
- + contentType: Ci.nsIContentPolicy.TYPE_OTHER,
- },
- {
- description: "should set request header for TYPE_DOCUMENT",
- expectingHeader: true,
- - contentType: Ci.nsIContentPolicy.TYPE_DOCUMENT
- + contentType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
- },
- {
- description: "should set request header for TYPE_SUBDOCUMENT",
- expectingHeader: true,
- - contentType: Ci.nsIContentPolicy.TYPE_SUBDOCUMENT
- + contentType: Ci.nsIContentPolicy.TYPE_SUBDOCUMENT,
- },
- {
- description: "should not set request header for TYPE_IMG",
- expectingHeader: false,
- - contentType: Ci.nsIContentPolicy.TYPE_IMG
- + contentType: Ci.nsIContentPolicy.TYPE_IMG,
- },
- ];
- @@ -46,23 +44,22 @@ function ChannelListener() {
- }
- ChannelListener.prototype = {
- - onStartRequest: function(request, context) { },
- - onDataAvailable: function(request, context, stream, offset, count) {
- + onStartRequest(request, context) { },
- + onDataAvailable(request, context, stream, offset, count) {
- do_throw("Should not get any data!");
- },
- - onStopRequest: function(request, context, status) {
- + onStopRequest(request, context, status) {
- var upgrade_insecure_header = false;
- try {
- if (request.getRequestHeader("Upgrade-Insecure-Requests")) {
- upgrade_insecure_header = true;
- }
- - }
- - catch (e) {
- + } catch (e) {
- // exception is thrown if header is not available on the request
- }
- // debug
- // dump("executing test: " + curTest.description);
- - Assert.equal(upgrade_insecure_header, curTest.expectingHeader)
- + Assert.equal(upgrade_insecure_header, curTest.expectingHeader);
- run_next_test();
- },
- };
- @@ -71,7 +68,7 @@ function setupChannel(aContentType) {
- var chan = NetUtil.newChannel({
- uri: URL + testpath,
- loadUsingSystemPrincipal: true,
- - contentPolicyType: aContentType
- + contentPolicyType: aContentType,
- });
- chan.QueryInterface(Ci.nsIHttpChannel);
- chan.requestMethod = "GET";
- diff --git a/dom/security/test/unit/test_isOriginPotentiallyTrustworthy.js b/dom/security/test/unit/test_isOriginPotentiallyTrustworthy.js
- --- a/dom/security/test/unit/test_isOriginPotentiallyTrustworthy.js
- +++ b/dom/security/test/unit/test_isOriginPotentiallyTrustworthy.js
- @@ -8,6 +8,7 @@
- ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
- ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
- +ChromeUtils.import("resource://gre/modules/Services.jsm");
- XPCOMUtils.defineLazyServiceGetter(this, "gScriptSecurityManager",
- "@mozilla.org/scriptsecuritymanager;1",
- @@ -17,8 +18,7 @@ XPCOMUtils.defineLazyServiceGetter(this,
- "@mozilla.org/contentsecuritymanager;1",
- "nsIContentSecurityManager");
- -var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
- -prefs.setCharPref("dom.securecontext.whitelist", "example.net,example.org");
- +Services.prefs.setCharPref("dom.securecontext.whitelist", "example.net,example.org");
- add_task(async function test_isOriginPotentiallyTrustworthy() {
- for (let [uriSpec, expectedResult] of [
- @@ -43,7 +43,7 @@ add_task(async function test_isOriginPot
- }
- // And now let's test whether .onion sites are properly treated when
- // whitelisted, see bug 1382359.
- - prefs.setBoolPref("dom.securecontext.whitelist_onions", true);
- + Services.prefs.setBoolPref("dom.securecontext.whitelist_onions", true);
- let uri = NetUtil.newURI("http://1234567890abcdef.onion/");
- let principal = gScriptSecurityManager.createCodebasePrincipal(uri, {});
- Assert.equal(gContentSecurityManager.isOriginPotentiallyTrustworthy(principal),
Add Comment
Please, Sign In to add comment