SitePermissions.get should check for nsIURI
Categories
(Firefox :: Site Identity, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: daleharvey, Assigned: phoenixgyaan)
References
Details
Attachments
(1 file)
Got confused by passing uri as a string here and not getting back what I expected, Johann asked me to file a bug to add a check here just so someone else doesnt make the same mistake in future
Updated•6 years ago
|
Comment 1•6 years ago
|
||
The idea here is that SitePermissions.getAllByURI, SitePermissions.get, SitePermissions.set and SitePermissions.remove take in an nsIURI as first parameter, but never really check that they actually got passed an nsIURI object (this can be done with uri instanceof Ci.nsIURI
). Each of these functions should throw an error if the uri parameter is not an nsIURI.
Assignee | ||
Comment 2•6 years ago
|
||
I would like to take this up please :)
Comment 3•6 years ago
|
||
Go for it! Would you like to be unassigned from bug 1500464, then?
Assignee | ||
Comment 4•6 years ago
|
||
Yes please, someone already has a patch for it :)
Assignee | ||
Comment 5•6 years ago
|
||
What are the STR for this.
Also, how do I confirm that the bug is fixed..???
Assignee | ||
Comment 6•6 years ago
|
||
And do we need to throw a general error using try-catch block, or do we have a pre-defined string that will need to be shown.
Comment 7•6 years ago
|
||
Please take a look at comment 1, this is a code-only change, there are no user-facing STR for this. You can just throw an error using the JS throw
keyword.
Thanks!
Assignee | ||
Comment 8•6 years ago
|
||
functions now throw an error if the uri parameter is not an nsIURI.
Comment 9•6 years ago
|
||
Since our change might break some existing (wrong) usage, it would be great to do a try run for your patch. Try is basically Continuous Integration for Firefox, making sure that tests are passing for your patch.
Getting access is outlined here: https://wiki.mozilla.org/ReleaseEngineering/TryServer#Getting_access_to_the_Try_Server
You will need to file a bug and need someone to vouch for you. I'd be happy to do that if you CC me on that bug.
After you've gotten access, to schedule a try run, you can use the handy ./mach try command. A possible syntax for this bug could be:
./mach try -b do -p win64,linux64,macosx64 -u mochitests -t none
(runs all mochitests on Windows, OSX and Linux)
Let me know if you need any help with that!
Assignee | ||
Comment 10•6 years ago
|
||
You will need to file a bug and need someone to vouch for you. I'd be happy to do that if you CC me on that bug.
Filed the bug here
Assignee | ||
Comment 11•6 years ago
|
||
You will need to file a bug and need someone to vouch for you. I'd be happy to do that if you CC me on that bug.
Filed the bug here
Assignee | ||
Comment 13•6 years ago
|
||
Hi Johann,
I have got the access, is there anything that I need to do on my codebase now..???
or can I simply run the command ./mach try -b do -p win64,linux64,macosx64 -u mochitests -t none
in my workspace..???
Comment 14•6 years ago
|
||
Hey, you'll need to make sure you perform the steps outlined in https://wiki.mozilla.org/ReleaseEngineering/TryServer#Configuration and (most importantly) in https://mozilla-version-control-tools.readthedocs.io/en/latest/hgmozilla/auth.html in order to get access on your local command line.
Then you can just run that command, yes :)
Assignee | ||
Comment 15•6 years ago
|
||
Hi Johann,
I got it running :)
https://treeherder.mozilla.org/#/jobs?repo=try&revision=942774ba2e27445bb68bb8fec86a57893cdb2e29
What is the next thing I should update you about..???
Assignee | ||
Comment 16•6 years ago
|
||
Ran the tests again after the changes made in test files.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=388124b353a2075ec0496a480bf1a9a4436c5e4e
Comment 17•6 years ago
|
||
Oh, wow, amazing, you found some issues with your patch!
Going through the list of failures, here's what I see:
This one is PermissionsUI.jsm passing "null" as a URI because it only wants to get temporary permission from the browser object. That seems fine to me, and you should probably adjust our check in SitePermissions.get
to allow a null URI if a browser was given (if ((!uri && !browser) || (uri && !(uri instanceof Ci.nsIURI)))
).
These two are clearly wrong, they should pass URI
instead.
This one probably means that we should apply the same null check for SitePermissions.remove and SitePermisions.set as well.
Can you make these changes in your patch?
Thank you!
Assignee | ||
Comment 18•6 years ago
|
||
Hi,
The changes are done to the patch.
The tests' status can be seen at:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=25c8e523073fd3fc23f0b209b953741ff034497a
Comment 19•6 years ago
|
||
That try looks good to me. You're all set to land your code! Please edit the bug (I've given you access to do so) and set the checkin-needed
keyword. Then somebody will come around and check the patch in for you.
Thanks!
Assignee | ||
Updated•6 years ago
|
Comment 20•6 years ago
|
||
Comment on attachment 9051289 [details]
Bug 1521919 - SitePermissions.get should check for nsIURI. r=johannh
Sorry, a different field, I'll do it :)
Updated•6 years ago
|
Assignee | ||
Comment 21•6 years ago
•
|
||
Sorry, I never did this before, so didn't knew which one it was.
Thank you :)
Comment 22•6 years ago
|
||
Pushed by rmaries@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/01cdf8342a49
SitePermissions.get should check for nsIURI. r=johannh
Comment 23•6 years ago
|
||
Backed out changeset 01cdf8342a49 (bug 1521919) for test_SitePermissions.js perma failures
push that caused the failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&selectedJob=235490376&revision=01cdf8342a49c2e06728f15835217f9d23b25cb9
backout: https://hg.mozilla.org/integration/autoland/rev/d9708fb342243b7459321e4a773bac1e448c59ee
Assignee | ||
Comment 24•6 years ago
|
||
Johann, how do I proceed with this..???
Comment 25•6 years ago
|
||
It seems like your test is failing on CI. Looking at it again it seems like the regex you're providing won't match the error, I think. Sorry for not catching that earlier.
Did you run the test locally at all? Unfortunately your try run didn't fail either, because I didn't specify xpcshell
in the syntax, so after fixing the test locally you should do another try like this:
./mach try -b do -p win64,linux64,macosx64 -u xpcshell -t none
Assignee | ||
Comment 26•6 years ago
•
|
||
On running tests locally using mach xpcshell-test
I got the following output at the end
xpcshell
~~~~~~~~
Ran 3672 checks (180 subtests, 3492 tests)
Expected results: 3439
Skipped: 203 tests
Unexpected results: 30
test: 18 (18 fail)
subtest: 12 (12 fail)
Unexpected Results
------------------
dom/push/test/xpcshell/test_register_success_http2.js
FAIL dom/push/test/xpcshell/test_register_success_http2.js - xpcshell return code: 0
dom/push/test/xpcshell/test_register_error_http2.js
FAIL dom/push/test/xpcshell/test_register_error_http2.js - xpcshell return code: 0
dom/push/test/xpcshell/test_unregister_success_http2.js
FAIL dom/push/test/xpcshell/test_unregister_success_http2.js - xpcshell return code: 0
dom/push/test/xpcshell/test_notification_http2.js
FAIL dom/push/test/xpcshell/test_notification_http2.js - xpcshell return code: 0
dom/push/test/xpcshell/test_registration_success_http2.js
FAIL dom/push/test/xpcshell/test_registration_success_http2.js - xpcshell return code: 0
netwerk/test/unit/test_immutable.js
FAIL netwerk/test/unit/test_immutable.js - xpcshell return code: 0
FAIL run_test - [run_test : 13] "" != ""
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/netwerk/test/unit/test_immutable.js:run_test:13
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:520
-e:null:1
netwerk/test/unit/test_http2.js
FAIL netwerk/test/unit/test_http2.js - xpcshell return code: 0
FAIL testOnStopRequest - [testOnStopRequest : 79] false == true
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/netwerk/test/unit/test_http2.js:testOnStopRequest:79
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_do_main:224
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:526
-e:null:1
netwerk/test/unit/test_altsvc.js
FAIL netwerk/test/unit/test_altsvc.js - xpcshell return code: 0
FAIL run_test - [run_test : 28] "" != ""
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/netwerk/test/unit/test_altsvc.js:run_test:28
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:520
-e:null:1
netwerk/test/unit/test_header_Server_Timing.js
FAIL netwerk/test/unit/test_header_Server_Timing.js - xpcshell return code: 0
browser/modules/test/unit/test_SitePermissions.js
FAIL browser/modules/test/unit/test_SitePermissions.js - xpcshell return code: 0
FAIL testNsIURI - [testNsIURI : 15] Missing expected exception. Should throw if arguments is not of type nsIURI.
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/browser/modules/test/unit/test_SitePermissions.js:testNsIURI:15
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:run_next_test/_run_next_test/<:1434
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_run_next_test:1434
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:run:685
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_do_main:224
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:526
-e:null:1
netwerk/test/unit/test_anonymous-coalescing.js
FAIL netwerk/test/unit/test_anonymous-coalescing.js - xpcshell return code: 0
FAIL run_test - [run_test : 20] "" != ""
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/netwerk/test/unit/test_anonymous-coalescing.js:run_test:20
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:520
-e:null:1
netwerk/test/unit/test_origin.js
FAIL netwerk/test/unit/test_origin.js - xpcshell return code: 0
FAIL run_test - [run_test : 14] "" != ""
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/netwerk/test/unit/test_origin.js:run_test:14
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:520
-e:null:1
netwerk/test/unit/test_trr.js
FAIL netwerk/test/unit/test_trr.js - xpcshell return code: 0
FAIL run_test - [run_test : 19] "" != ""
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/netwerk/test/unit/test_trr.js:run_test:19
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:520
-e:null:1
netwerk/test/unit/test_esni_dns_fetch.js
FAIL netwerk/test/unit/test_esni_dns_fetch.js - xpcshell return code: 0
FAIL run_test - [run_test : 17] "" != ""
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/netwerk/test/unit/test_esni_dns_fetch.js:run_test:17
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:520
-e:null:1
security/manager/ssl/tests/unit/test_nonascii_path.js
FAIL security/manager/ssl/tests/unit/test_nonascii_path.js - xpcshell return code: 0
FAIL undefined assertion name - the profile short path should contain a non-ASCII character - false == true
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/security/manager/ssl/tests/unit/test_nonascii_path.js:null:24
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:load_file:634
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_load_files:646
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:500
-e:null:1
toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
FAIL toolkit/components/crashes/tests/xpcshell/test_crash_manager.js - xpcshell return code: 0
FAIL test_child_process_crash_ping - [test_child_process_crash_ping : 532] 1552633200000 == 1552635000000
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js:test_child_process_crash_ping:532
toolkit/components/search/tests/xpcshell/test_geodefaults.js
FAIL toolkit/components/search/tests/xpcshell/test_geodefaults.js - xpcshell return code: 0
FAIL should_get_geo_defaults_only_once - [should_get_geo_defaults_only_once : 49] "undefined" == "number"
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/toolkit/components/search/tests/xpcshell/test_geodefaults.js:cont:49
toolkit/mozapps/update/tests/unit_service_updater/checkUpdaterSigSvc.js
FAIL toolkit/mozapps/update/tests/unit_service_updater/checkUpdaterSigSvc.js - xpcshell return code: 0
FAIL run_test - [run_test : 37] the maintenance service exit value should be 0 - 1 == 0
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/toolkit/mozapps/update/tests/unit_service_updater/checkUpdaterSigSvc.js:run_test:37
i:\Mozilla\mozilla-central\testing\xpcshell\head.js:_execute_test:520
-e:null:1
Tests were run in parallel. Try running with --sequential to make sure the failures were not caused by this.
The only line where my changed file failed was at
browser/modules/test/unit/test_SitePermissions.js
FAIL browser/modules/test/unit/test_SitePermissions.js - xpcshell return code: 0
FAIL testNsIURI - [testNsIURI : 15] Missing expected exception. Should throw if arguments is not of type nsIURI.
So, is this regex causing the failure of tests ->/Not_nsIURI_Error/
Assignee | ||
Comment 27•6 years ago
|
||
Hi Johann I am stuck here.
I have changed the code to
.
.
.
add_task(async function testNsIURI() {
let uri = "http://foo.com/bar/baz";
const expectedError = /uri parameter should be an nsIURI/;
Assert.throws(() => SitePermissions.getAllByURI(uri),
expectedError,
"Should throw if arguments is not of type nsIURI.");
.
.
.
But still the test result comes out as
.
.
.
xpcshell
~~~~~~~~
Ran 2 checks (1 subtests, 1 tests)
Expected results: 0
Unexpected results: 2
test: 1 (1 fail)
subtest: 1 (1 fail)
Unexpected Results
------------------
browser/modules/test/unit/test_SitePermissions.js
FAIL testNsIURI - [testNsIURI : 16] Missing expected exception. Should throw if arguments is not of type nsIURI.
i:/Mozilla/mozilla-central/objdir-frontend/_tests/xpcshell/browser/modules/test/unit/test_SitePermissions.js:testNsIURI:16
.
.
.
Comment 28•6 years ago
|
||
This works fine for me, can you please upload the updated patch so that I have more context to that failure?
Assignee | ||
Comment 29•6 years ago
|
||
I have updated the patch in Phabricator.
Please have a look
Comment 30•6 years ago
|
||
Hey, I'm really sorry for the delay, this is working fine for me and I can't see why it wouldn't. I'm going to land this for you :)
Thanks!
Comment 31•6 years ago
|
||
Comment 32•6 years ago
|
||
bugherder |
Description
•