MozillaReality / WebXR-emulator-extension

INACTIVE - WebXR emulator extension
Mozilla Public License 2.0
462 stars 55 forks source link

How to use WebXR emulator to test using Puppeteer? #282

Closed r03ert0 closed 2 years ago

r03ert0 commented 2 years ago

I'm writing a WebXR app, and I would like to write tests for its functions. I'm trying to use Puppeteer. First I tried with Chromium, but I can't install WebXR with Chromium. That's not a problem, however, because Puppeteer can also be used with Chrome. However, when Puppeteer launches Chrome, all extensions are disabled. I tried passing the ignoreDefaultArgs: ["--disable-extensions"] option when launching Puppeteer, but WebXR is disabled nevertheless (The "Enter VR" button says "VR not supported" instead).

How do you test WebXR code? Is there a way of forcing Puppeteer to load the WebXR emulator? Is there maybe another preferred way of testing WebXR code?

Thanks in advance!

r03ert0 commented 2 years ago

I found how to do it \o/ I had to load the extension from its location in my filesystem:

const browser = await puppeteer.launch({
  headless:false,
  devtools: true,
  executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
  ignoreDefaultArgs: [
    "--disable-extensions",
    "--enable-automation"
  ],
  args: [
    "--ignore-certificate-errors",
    `--load-extension=/Users/roberto/Library/Application\ Support/Google/Chrome/Default/Extensions/mjddjgeghkdijejnciaefnkjmkafnnje/0.3.3_0`
  ]});

Now I have a window that opens with WebXR enabled. I make Puppeteer click on that button, and bim!

r03ert0 commented 2 years ago

actually, the executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' part is not necessary.