Clone Browser #58

Open
Migrate opened this Issue Aug 1, 2011 · 0 comments

Projects

None yet

1 participant

@Migrate
Migrate commented Aug 1, 2011

Hi,

I've create a clone browser function so I can create new browser with the same cookieJar.

browser.js:

/**
 * Clone a new `Browser` with the same cookieJar, external options and userAgent as the sourceBrowser.
 *
 * @param {Object} source browser.
 * @api public
 */
Browser.prototype.cloneBrowser = function(sourceBrowser) {
    this.external = sourceBrowser.external;
    this.cookieJar = sourceBrowser.cookieJar;
    this.userAgent = sourceBrowser.userAgent;
};

tobi.js:

/**
 * Initialize a new `Browser` with the same cookieJar and userAgent 
 */
exports.cloneBrowser = function(a,b,c,d){
  new_browser = new exports.Browser(a,b,c);
  new_browser.cloneBrowser(d)
  return new_browser;
};

I need this function because I have several hosts that share the same cookies.

default_browser = tobi.createBrowser(80, default_host, { external: true });
new_brower = tobi.cloneBrowser(80, new_host, {}, browser);

Can you please add this function (or something similar) to the next release?
Thanks.
Best regards,
Migrate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment