Closed Bug 1355166 Opened 7 years ago Closed 6 years ago

Remove remote newtab's dead code

Categories

(Firefox :: New Tab Page, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 60
Tracking Status
firefox60 --- fixed

People

(Reporter: ursula, Assigned: adam.kasztenny)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 4 obsolete files)

Files found in browser/components/newtab used to belong to the remote newtab project. Since this died we should get rid of the dead code. 
One approach is what is mentioned in bug 1329955
As noted in bug 1360316, there was some problems caused by relying on dead code as NewTabPrefsProvider is no longer being `init`ed.
Depends on: 1360316
Keywords: good-first-bug
I'd like to work on this.
Is there a good way to just remove the "remote newtab" stuff without impacting tiles and activity stream? In particular, both depend on aboutNewTabService but probably not everything in browser/components/newtab

https://searchfox.org/mozilla-central/search?q=aboutNewTabService

Any good way for Adam to test if things get broken or not when cleaning up?
Flags: needinfo?(usarracini)
Hey Adam, thanks for your interest here. 

You can delete everything in browser/components/newtab EXCEPT for aboutNewTabService, also delete https://dxr.mozilla.org/mozilla-central/source/browser/base/content/test/static/browser_all_files_referenced.js#93-95, and also delete test_NewTabPrefsProvider.js and test_NewTabSearchProvider.js in browser/components/newtab/tests/xpcshell - that means removing them from xpcshell.ini as well. 

As a first step, make sure to run the tests in browser/components/newtab/tests to make sure they're still good. If you want to make sure tiles code isn't busted you can run the tests in browser/base/content/test/newtab and make sure they still pass. But really, running it on try is your best bet to make sure nothing is broken. If you don't have try privileges, I can apply your patch and run the test suite to double check. The remote newtab code should be pretty isolated, so nothing should be breaking the new stuff when removed, and as long as you remove all the stuff mentioned above, you should be ok.

There's also some content signing stuff that's left over in https://dxr.mozilla.org/mozilla-central/source/dom/security/ContentVerifier.cpp#51, and tests associated with it: https://dxr.mozilla.org/mozilla-central/source/security/manager/ssl/tests/unit/test_content_signing.js#15. This should also be dead code
Flags: needinfo?(usarracini)
Thanks a lot for the information. Does it make sense to run the entire test suite locally before submitting the patch? Or does that take too long? (I'm new here, and I haven't tried running any tests yet)
I wouldn't run the entire test suite locally, that would take much too long! The great thing about try is that you can run it on multiple platforms. I think starting with the tests that I mentioned above is good, and then I can push it to try and see if there's anything else broken :)

Have you run tests locally before?
Okay, thanks, I'll do that then. I haven't tried running any tests locally yet.
I was able to run tests fine. Everything passed before I started deleting things, and afterwards as well. I ended up deleting:

browser/components/newtab/NewTabPrefsProvider.jsm
browser/components/newtab/NewTabRemoteResources.jsm
browser/components/newtab/NewTabSearchProvider.jsm
browser/components/newtab/NewTabWebChannel.jsm
browser/components/newtab/tests/xpcshell/test_NewTabPrefsProvider.js
browser/components/newtab/tests/xpcshell/test_NewTabSearchProvider.js

along with modifying moz.build and xpcshell.ini.

However, I'm not sure what to delete from https://dxr.mozilla.org/mozilla-central/source/dom/security/ContentVerifier.cpp (it seems to be used, along with its init method which references newtab) and from the tests, https://dxr.mozilla.org/mozilla-central/source/security/manager/ssl/tests/unit/test_content_signing.js (should I delete every test that makes reference to newtab?).

When I'm done, how should I submit my patch? Should I post it here or email it to you?

Thanks.
Hey Franziskus, Adam is working on removing some of the leftover dead code for remote newtab, some code was added for Bug 1263793 that can probably be deleted now, including some tests in dom/security/test/contentverifier/. Would you be able to provide Adam some help on what parts can be deleted in ContentVerifier.cpp and which tests to make sure are ok?

If it's out of scope for this patch, or a first time contributor, then maybe we can just stick to removing the dead code in browser/components/newtab and file another bug to remove the content signing bits later? What do you think Franziskus?

Adam, when you're finished with the patch, submit it as an attachment to this Bug so we can review it and land it for you.
Flags: needinfo?(franziskuskiefer)
> some code was added for Bug 1263793 that can probably be deleted now, including some tests in dom/security/test/contentverifier/

The tests can definitely be deleted. They are disable anyway.

The only two services (I know of) using content signatures right now are blocklist updates and normandy. They both use the CS service directly. So I think ContentVerifier.cpp can go completely. To make that work there are changes to nsHTTPChannel necessary.
However, before doing that it might be advisable to check whether this is used anywhere else. I don't think it is and a quick check doesn't reveal any callers of LoadInfo::SetVerifySignedContent (and without it content signature verification is not invoked from nsHTTPChannel). The LoadInfo bits can be removed as well then as it can't really be used anymore.
This is touching a couple different parts but I think it's all dead code right now and should probably be removed.
Flags: needinfo?(franziskuskiefer)
Thanks. nsHTTPChannel seems to be still used. What file/function are you referring to when you say "whether this is used anywhere else"?
This patch doesn't include any of the cpp changes.
> nsHTTPChannel seems to be still used. 

nsHTTPChannel is our HTTP channel so that won't go away ;) But it calls functions from ContentVerifier.cpp. So you can't remove ContentVerifier.cpp without touching nsHTTPChannel.

> What file/function are you referring to when you say "whether this is used anywhere else"?

Any public function from ContentVerifier. If it's used in a context that's not protected by the SetVerifySignedContent LoadInfo flag, or the SetVerifySignedContent LoadInfo flag is set anywhere, then it's used. (I don't think that's the case but you should probably double check.)
Thanks. So I should remove the unused functions from ContentVerifier?
Ursula, could you please check if any tests are broken as a result of my JS changes in the patch?
Hey Adam, can you rebase this patch on the latest mozilla-central? I'm not getting a clean apply
Yeah, I'll do that.
Okay, the patch should be ready to go now.
Attachment #8951873 - Flags: review?(usarracini)
Attachment #8949073 - Attachment is obsolete: true
Try push for the most recent patch: https://treeherder.mozilla.org/#/jobs?repo=try&revision=bb7cc4c93092b7391daf63e3f5ef3e9d7e8b2c2f

If this is green then I'll start the review. Thanks for the rebase Adam!
Adam, you'll need to delete these lines of code: https://dxr.mozilla.org/mozilla-central/rev/c38d22170d6f27e94c3c53093215d20255fab27a/browser/base/content/test/static/browser_all_files_referenced.js#93-95

That will fix some of the initial test failures from the try push.
Attachment #8951873 - Attachment is obsolete: true
Attachment #8951873 - Flags: review?(usarracini)
Attached patch The rebased patch with the fix (obsolete) — Splinter Review
Attachment #8952578 - Flags: review?(usarracini)
I see 3 test failures. Are these all unrelated to my changes?
They don't look related to your changes. I'll have a review for you done today :)
Excellent, thanks!
I think you can remove the remaining file dom/security/test/contentverifier/file_contentserver.sjs. So you can remove the entire folder
Attachment #8952578 - Attachment is obsolete: true
Attachment #8952578 - Flags: review?(usarracini)
Attachment #8953296 - Flags: review?(usarracini)
Comment on attachment 8953296 [details] [diff] [review]
Bug 1355166 - Remove remote newtab's dead code r=ursula

This looks good to me. We can properly remove ContentVerifier.cpp as a follow up bug, but this is a good start. Thanks!
Attachment #8953296 - Flags: review?(usarracini) → review+
Can you change the commit message to be:
"Bug 1355166 - Remove remote newtab's dead code r=ursula"
And we can set check-in needed to land it
Attachment #8953296 - Attachment description: Latest patch, with all of dom/security/test/contentverifier/ deleted → Bug 1355166 - Remove remote newtab's dead code r=ursula
Thanks, I changed the name of the patch. I'll start on the CPP changes.
If you want to make the patch for the cpp changes on this bug, make sure to attach the patch as a separate attachment from the JS changes, and probably ask Franziskus for review on that one.
Yes, I'll be sure to do that.
A few files that I deleted were just changed today:

browser/components/newtab/NewTabPrefsProvider.jsm
browser/components/newtab/NewTabRemoteResources.jsm                                                                                                                  
browser/components/newtab/NewTabSearchProvider.jsm                                                                                                                    
browser/components/newtab/NewTabWebChannel.jsm
Looks like bug 1440284. Should still be able to just delete them.
Should the status of this bug be changed to "check-in needed"?
Well that depends, if you want to file the c++ changes in a different bug then yes I can set check-in needed, but I thought you were planning on attaching the changes to this bug? If so we have to wait for all the changes to be ready to land, then change the bug status so both patches can land
Oh okay, I thought it could be done in parts. I'll leave it up to you whether the C++ changes should be done in a different bug or this one. I'm fine either way.
Let's just do them in a separate bug so this can land. I can file it. Thanks!
Thank you!
Assignee: nobody → adam.kasztenny
Filed bug 1441989 for deleting ContentVerifier.cpp. And assigned Adam
This patch fails to apply. Please take a look at it. Thanks!

applying 1355166-with-fix-2.patch
patching file browser/components/newtab/NewTabPrefsProvider.jsm
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file browser/components/newtab/NewTabPrefsProvider.jsm.rej
patching file browser/components/newtab/NewTabRemoteResources.jsm
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file browser/components/newtab/NewTabRemoteResources.jsm.rej
patching file browser/components/newtab/NewTabSearchProvider.jsm
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file browser/components/newtab/NewTabSearchProvider.jsm.rej
patching file browser/components/newtab/NewTabWebChannel.jsm
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file browser/components/newtab/NewTabWebChannel.jsm.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working directory
errors during apply, please fix and qrefresh 1355166-with-fix-2.patch
Flags: needinfo?(usarracini)
Keywords: checkin-needed
Pretty sure the patch needs to be rebased as per comment 36
Flags: needinfo?(usarracini) → needinfo?(adam.kasztenny)
Yep, thanks. I'll do that.
Flags: needinfo?(adam.kasztenny)
Attachment #8953296 - Attachment is obsolete: true
Attachment #8954987 - Flags: checkin?(csabou)
Keywords: checkin-needed
Attachment #8954987 - Flags: checkin?(csabou)
Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/42c835f417b5
Remove remote newtab's dead code. r=ursula
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/42c835f417b5
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Blocks: 1329955
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: