ps-analysis-tool icon indicating copy to clipboard operation
ps-analysis-tool copied to clipboard

Feature: Complete migration to CDP

Open amovar18 opened this issue 11 months ago • 0 comments

Description

This PR aims to use CDP completely rather than using the chrome.webRequest API along with CDP.

Relevant Technical Choices

Frame Tree Creation and Tab Identification:

  • FrameIds received in the requestWillBeSent and responseReceived are sometimes not available in the chrome.debugger.getTargets().
  • We use 'Page.frameAttached` to create a frameTree of the frames being added in the Tab.
  • The source.TabId is sometimes undefined instead source.targetId is defined which we use to look into the frameTree of the tab if that target exists then we get the TabId of the tab and use it to update.
  • PSAT also tracks additional frames that are recorded in the serviceWorker for a Tab. These frames along with frameIds are sent to the DevTools so that the extra frameIds can be appended to the frameIds being used in DevTools.

Cookie analysis:

  • requestWillBeSent and responseReceived events provide frameId and urls.
  • responseReceivedExtraInfo and requestWillBeSentExtraInfo provide information about cookies.
  • extraInfo is not processed until their respective requestWillBeSent or responseReceived has not arrived.
  • If the extraInfo arrives before their counterpart, they are stored in a map. Once the counterpart arrives they are processed.
  • If extraInfo arrives after the counterpart, they are processed immediately.
  • Along with the above the resource URLs of the PSAT analysed are kept in a set where all the resource URLs belonging to a frameId are stored.
  • These resource URLs are used to supplement data from Network.getCookies every 5 seconds to avoid any mismatch of the data.

Testing Instructions

  • Clone this branch.
  • Launch a new browser instance with the PSAT installed.
  • Open any site then open DevTools then navigate to the PSAT tab in DevTools.
  • Click on Enable CDP then click on Reload.
  • Once CDP is enabled you can click on analyse this tab.
  • Now you should see cookies data being loaded.

Additional Information:

Screenshot/Screencast


Checklist

  • [x] I have thoroughly tested this code to the best of my abilities.
  • [x] I have reviewed the code myself before requesting a review.
  • [ ] This code is covered by unit tests to verify that it works as intended.
  • [ ] The QA of this PR is done by a member of the QA team (to be checked by QA).

amovar18 avatar Mar 01 '24 04:03 amovar18