Closed Bug 1608294 Opened 5 years ago Closed 1 year ago

Allow to send referrer via Page.navigate

Categories

(Remote Protocol :: CDP, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: whimboo, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [puppeteer-beta2-mvp] )

Currently it is not possible to set a referrer for Page.navigate(). That's happening because the referrer string gets set instead of a nsIReferrerInfo instance. Juggler does it like the following:

    let referrerURI = null;
    let referrerInfo = null;
    if (referer) {
      try {
        referrerURI = NetUtil.newURI(referer);
        const ReferrerInfo = Components.Constructor(
          '@mozilla.org/referrer-info;1',
          'nsIReferrerInfo',
          'init'
        );
        referrerInfo = new ReferrerInfo(Ci.nsIHttpChannel.REFERRER_POLICY_UNSET, true, referrerURI);
      } catch (e) {
        throw new Error(`Invalid referer: "${referer}"`);
      }
    }
    const frame = this._frameTree.frame(frameId);
    const docShell = frame.docShell().QueryInterface(Ci.nsIWebNavigation);
    docShell.loadURI(url, {
      flags: Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
      referrerInfo,
      postData: null,
      headers: null,
    });

Maja, can you please check if we would need that for beta2?

Flags: needinfo?(mjzffr)
Blocks: 1636477

Puppeteer's Page.goto accepts a referer option. By default, it uses "the referer header value set by page.setExtraHTTPHeaders()".

Given that we've included Network.setExtraHTTPHeaders in beta2 (Bug 1637063), we might want to prioritize referrer via Page.navigate in order to integrate its use properly in Puppeteer.

That being said, I don't see any explicit usage of page.setExtraHTTPHeaders or referer options in WP Gutenberg. It seems the Fetch domain is rather more important there.

Flags: needinfo?(mjzffr)
Whiteboard: [puppeteer-beta2-mvp]
Component: CDP: Page → CDP
Severity: normal → S3

If such a feature is needed by consumers of the protocol we should put our focus on WebDriver BiDi instead, which already has a way better navigation implementation.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.