Closed Bug 1274223 Opened 8 years ago Closed 8 years ago

Test if nsUrlClassifierHashCompleter.js sends expected completion request.

Categories

(Toolkit :: Safe Browsing, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: hchang, Assigned: hchang)

Details

Attachments

(1 file, 1 obsolete file)

It's currently unable to test since the prefixes would be shuffled before being assembled to one single HTTP request. What we can do is either of the following:

1) Add a preference and modify nsUrlClassifierHashCompleter.js to avoid shuffling prefixes while running the test case.

2) Do not byte-wise compare the request. Compare if all prefixes are present in the request. (split the request according to the prefix length then compare ...)

3) Only verify the request when there is only one prefix in the request.

I personally prefer (1).
Assignee: nobody → hchang
Attached patch WIP patch (obsolete) — Splinter Review
If we do (1) (mentioned in the description), the test is as simple as attachment 8754305 [details] [diff] [review]
Hi Francois, May I have your feedback on this bug? Thanks :)
Flags: needinfo?(francois)
(In reply to Henry Chang [:henry] from comment #0)
> It's currently unable to test since the prefixes would be shuffled before
> being assembled to one single HTTP request. What we can do is either of the
> following:
> 
> 1) Add a preference and modify nsUrlClassifierHashCompleter.js to avoid
> shuffling prefixes while running the test case.

I'm not sure I understand what you mean by the shuffling of the prefixes. Do you mean that if you request a completion for more than one prefix, they are reordered randomly?

If so, one thing we could do is sort them. That way the order would be deterministic and we could rely on it in our tests.

I'm a little bit wary of adding a pref just for our tests because then we're not actually testing the real configuration. Sometime that's inevitable, but if we can avoid it that would be great.

> 2) Do not byte-wise compare the request. Compare if all prefixes are present
> in the request. (split the request according to the prefix length then
> compare ...)

Whilte that's more work, it sounds like a good approach.

> 3) Only verify the request when there is only one prefix in the request.

That option wouldn't work because we always send more than one prefix in completion requests (we add 3 "noise" entries by default).
Flags: needinfo?(francois)
Attached patch Patch v1Splinter Review
Attachment #8754305 - Attachment is obsolete: true
Attachment #8755379 - Flags: review?(francois)
Comment on attachment 8755379 [details] [diff] [review]
Patch v1

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

::: toolkit/components/url-classifier/tests/unit/test_hashcompleter.js
@@ +141,5 @@
> +
> +  let partialLength = parseInt(tokens[1]);
> +  let payloadLength = parseInt(tokens[2]);
> +
> +  let payloadStart = tokens[1].length + // partial length

These comments are very useful in making this part easy to understand. Thanks!
Attachment #8755379 - Flags: review?(francois) → review+
Keywords: checkin-needed
This landed with the wrong bug number (it had landed with bug 1274226):

https://hg.mozilla.org/integration/fx-team/rev/f03b60a446f1
https://hg.mozilla.org/mozilla-central/rev/f03b60a446f1
Status: NEW → RESOLVED
Closed: 8 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: