Git Product home page Git Product logo

Comments (5)

aslushnikov avatar aslushnikov commented on April 28, 2024

@paulirish @pavelfeldman guys, guys. WDYT?

from puppeteer.

pavelfeldman avatar pavelfeldman commented on April 28, 2024

Not sure if this makes things any better. Today, device is a pair or {viewport, userAgent}. It seems that the only change that you suggest is merging them into a single device entity and introducing a new emulateDevice method? Although that is fine with me, it makes UA emulation redundant (you already have specific methods for UA emulation). Looks like super-minor sugar overall. Today you can do:

// If needed, a hand-made device could be done
let device = {
  width: 100,
  height: 100,
  deviceScaleFactor: 2
});

page.setViewport(device);
// When I want UA,
page.setUserAgent(deviceUserAgent);

from puppeteer.

aslushnikov avatar aslushnikov commented on April 28, 2024

It seems that the only change that you suggest is merging them into a single device entity and introducing a new emulateDevice method?

That's right. Here's a summary of the changes:

  • make page.emulateDevice(deviceConfig) instead of page.emulate(deviceName) so that there's a single entry point for device emulation
  • make page.setOrientation method so that orientation is not a part of a viewport
  • expose pre-built devices as structs in the top-level require to make it simple to inspect devices and their emulation configs

Although that is fine with me, it makes UA emulation redundant (you already have specific methods for UA emulation).

It's still nice to have both setUserAgent and setViewport methods - they might come handy at times. However, I think that a lot of times those who use page.setUserAgent or page.setViewport would rather emulate some device.

from puppeteer.

pavelfeldman avatar pavelfeldman commented on April 28, 2024
const samsungDevices = requires(./sd);
const devices = require(puppeteer/DeviceDescriptors);

await page.emulateDevice(samsungDevices['GSIII_landscape']);
  await page.setViewport(device.viewport);
  await page.setUserAgent(device.ua));

from puppeteer.

aslushnikov avatar aslushnikov commented on April 28, 2024

With the last patch, everything we've discussed is done. There's no page.emulateDevice for now, instead it's suggested to use setViewport / setUserAgent methods explicitly.

I've updated the doc to explain about emulation: emulation

from puppeteer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.