1# Loading autotestPrivate extension on your device 2 3AutotestPrivate is an extension that exposes APIs that facilitate the 4interaction with a ChromeOS device during tests. This guide shows how to load 5the extension on your device. 6 7[TOC] 8 9 10## Prerequisites 11 12You need a device running a ChromeOS test image and a Chromium OS 13checkout. To load a test image on your device follow [these steps] from the 14Simple Chrome guide. To grab a checkout of Chromium OS follow the 15[OS Developer Guide]. 16 17 18## Removing rootfs verification and editing command line flags 19NOTE: If you've completed these steps before feel free to skip to [Loading 20autotest extension on your device](#Loading-autotest-extension-on-your-device) 21 22To get a command shell on the device: 23 241. Run in your workstation: 25 26 `ssh root@$IP_ADDR` 27 28 Use the default password: 29 30 `test0000` 31 321. To run ChromeOS with flags, first make usr partition writeable with: 33 34 ``` 35 /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 2 36 /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 4 37 ``` 38 391. Reboot your device for rootfs changes to take effect. Run: 40 41 `reboot` 42 431. Then append desired flags(listed below) to `/etc/chrome_dev.conf`. 44 45## Loading autotest extension on your device 46 471. Enter a ChromeOS chroot. Inside of your ChromeOS checkout directory run: 48 49 `cros_sdk` 50 511. From inside your ChromeOS chroot run: 52 53 `test_that $IP_ADDR -b $BOARD stub_Pass` 54 55 This will install the autotestPrivate extension manifest to your device. 56 571. Open a command prompt in your device and edit your command line flags. 58 59 * Add flag `--remote-debugging-port=9333` 60 * NOTE: Port 9333 is not required, any port will work. 61 * Add flag 62 `--load-extension=/usr/local/autotest/common_lib/cros/autotest_private_ext` 63 641. In your device's command prompt run 65 66 `restart ui` 67 68 for flag changes to take effect. 69 701. Ssh to your device with `ssh -L 9333:localhost:9333 root@$IP_ADDR` 71 72 This will forward your device's devtools port to a local port on your 73 workstation. 74 751. On your workstation, point your browser to `localhost:9333`. 76 771. Click on *Telemetry ChromeOS AutoTest Component Extension*. This opens a 78 connection to the extension's backgound page. 79 801. Open the console tab. 81 82If you've followed all the steps correctly, you should be able to execute code 83in the console tab to interact with the extension. 84 85For example, try running: 86``` js 87> chrome.autotestPrivate.loginStatus(status => console.log(status)); 88> {isLoggedIn: false, isOwner: false, isReadyForPassword: false, isScreenLocked: false} 89``` 90 91\[these steps\]: https://chromium.googlesource.com/chromiumos/docs/+/main/simple_chrome_workflow.md#set-up-the-chrome-os-device <br> 92\[OS Developer Guide\]: https://chromium.googlesource.com/chromiumos/docs/+/main/developer_guide.md#get-the-source 93