make head.js file to reduce copy-paste in psm unit tests

RESOLVED FIXED in mozilla24

Status

()

Core
Security: PSM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: cviecco, Assigned: cviecco)

Tracking

unspecified
mozilla24
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 4 obsolete attachments)

Comment hidden (empty)
(Assignee)

Comment 1

5 years ago
Created attachment 755655 [details] [diff] [review]
unit-psm-head (v1)

version 1 only common stuff. Wished more could get in.
Attachment #755655 - Flags: feedback?(dkeeler)
(Assignee)

Comment 2

5 years ago
try push (all platforms, only xpcshell tests)
https://tbpl.mozilla.org/?tree=Try&rev=8c8fa0549d0
Comment on attachment 755655 [details] [diff] [review]
unit-psm-head (v1)

Review of attachment 755655 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great. How about an addCertFromFile function like this:

function addCertFromFile(filename, trustString) {
  let certdb = Cc["@mozilla.org/security/x509certdb;1"]
                 .getService(Ci.nsIX509CertDB);
  let certFile = do_get_file(filename, false);
  let der = readFile(certFile);
  certdb.addCert(der, trustString, null);
}

::: security/manager/ssl/tests/unit/head.js
@@ +6,5 @@
> +const { 'classes': Cc, 'interfaces': Ci, 'utils': Cu, 'results': Cr } = Components;
> +
> +let tempScope = {};
> +Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
> +let NetUtil = tempScope.NetUtil;

In terms of temporary scope, this is what I've been doing:

let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});

::: security/manager/ssl/tests/unit/test_datasignatureverifier.js
@@ +1,2 @@
> +//const Cc = Components.classes;
> +//const Ci = Components.interfaces;

Just remove these entirely?

::: security/manager/ssl/tests/unit/xpcshell.ini
@@ +3,1 @@
>  tail = 

these lines look like they already had a trailing space - I would say go ahead an remove them (the spaces)
Attachment #755655 - Flags: feedback?(dkeeler) → feedback+
(Assignee)

Comment 4

5 years ago
Created attachment 755678 [details] [diff] [review]
unit-psm-head (v2)
Attachment #755655 - Attachment is obsolete: true
(Assignee)

Comment 5

5 years ago
Created attachment 755679 [details] [diff] [review]
unit-psm-head (v2.1)

removal of comment change from v2
Attachment #755678 - Attachment is obsolete: true
(Assignee)

Updated

5 years ago
Attachment #755679 - Flags: review?(bsmith)
Comment on attachment 755679 [details] [diff] [review]
unit-psm-head (v2.1)

Review of attachment 755679 [details] [diff] [review]:
-----------------------------------------------------------------

Nit: IMO, "head_psm.js" is a better name because it is easier to distinguish from other "head.js" files open in other editor tabs/buffers.

::: security/manager/ssl/tests/unit/head.js
@@ +1,3 @@
> +/*
> +  Some license here (or not, bsmith?)
> +*/

I guess just use the standard MPL block and mode line (adjusted C++ -> JS):
https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style#Mode_Line
Attachment #755679 - Flags: review?(bsmith) → review+
(Assignee)

Comment 7

5 years ago
Created attachment 756135 [details] [diff] [review]
unit-psm-head (v3)
Attachment #755679 - Attachment is obsolete: true
Attachment #756135 - Flags: review+
(Assignee)

Comment 8

5 years ago
Created attachment 756139 [details] [diff] [review]
unit-psm-head (v3.1)

keeping r+ from bsmith
Attachment #756135 - Attachment is obsolete: true
Attachment #756139 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/112708de0e15
Assignee: nobody → cviecco
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.