Skip to content

Instantly share code, notes, and snippets.

View stephendonner's full-sized avatar

Stephen Donner stephendonner

View GitHub Profile
@stephendonner
stephendonner / gist:1097ad91f3bc53d2682523709e64f818
Last active December 3, 2019 06:37
[conditioned-profile] back-to-basics Raptor unittests run with Tarek's patch from https://bugzilla.mozilla.org/attachment.cgi?id=9103867&action=edit
[conditioned-profile] back-to-basics Raptor unittests run with Tarek's patch from https://bugzilla.mozilla.org/attachment.cgi?id=9103867&action=edit
Steps reflected here:
1. clone fresh mozilla-unified tree
2. download and apply patch (hg import) from https://bugzilla.mozilla.org/attachment.cgi?id=9103867&action=edit
3. hg wip to show we're on tip
4. now, we remove the `mozilla.pth:testing/condprofile` line from the working tree
5. run Raptor unittests using --python 2 (./mach python-test -v --python 2 --subsuite raptor)
6. Raptor-unittests failures
7. our virtualenv is at /Users/sdonner/mozilla-source/mozilla-unified/obj-x86_64-apple-darwin18.7.0/_virtualenvs/mozilla-unified-evYUFdVP-2 for this run:
@stephendonner
stephendonner / gist:ddab5b349f494a33b1904093dcd5ee15
Last active April 18, 2019 05:06
Builds for power-usage baselining
Fennec (Firefox 64.0.2): https://archive.mozilla.org/pub/mobile/releases/64.0.2/android-api-16/en-US/fennec-64.0.2.en-US.android-arm.apk
RefBrow: https://index.taskcluster.net/v1/task/project.mobile.reference-browser.signed-nightly.nightly.2019.4.9.latest/artifacts/public/target.arm.apk
Fenix: https://index.taskcluster.net/v1/task/project.mobile.fenix.signed-nightly.nightly.2019.4.9.latest/artifacts/public/target.arm.apk
GVE: https://taskcluster-artifacts.net/dzV5pl0SRz6IvbIDR1TEIA/0/public/build/geckoview_example.apk
@stephendonner
stephendonner / gist:0ebec0776aefdd0e205e5f1fe10c247c
Created March 23, 2019 01:25
My zsh shell-command history, working on Android power-use/battery-level testing
stephendonner/moz_src/mozilla-unified on  (git)-[master|rebase]- [=✘»!+?] on ☿ default is 📦 ⚠ via 𝗥 v1.32.0 via 🐍 system
➜ adb shell am start -n org.mozilla.firefox/org.mozilla.gecko.BrowserApp -a android.intent.action.VIEW -d 'data%3Atext%2Fhtml%2C%3Cbody%20style%3D%22background-color%3Ablack%22%3E'
Starting: Intent { act=android.intent.action.VIEW dat=data:text/html,<body style="background-color:black"> cmp=org.mozilla.firefox/org.mozilla.gecko.BrowserApp }
Warning: Activity not started, its current task has been brought to the front
stephendonner/moz_src/mozilla-unified on  (git)-[master|rebase]- [=✘»!+?] on ☿ default is 📦 ⚠ via 𝗥 v1.32.0 via 🐍 system
➜ adb shell am start -n org.mozilla.firefox/org.mozilla.gecko.BrowserApp -a android.intent.action.VIEW -d https://www.wikihow.com/Set-Background-Color-in-HTML
Starting: Intent { act=android.intent.action.VIEW dat=https://www.wikihow.com/... cmp=org.mozilla.firefox/org.mozilla.gecko.BrowserApp }
Warning: Activity not started, its c
@stephendonner
stephendonner / raptor-test-list.txt
Last active February 26, 2019 06:59
List of Raptor Tests
Stephens-MacBook-Pro:mozilla-central stephendonner$ ./mach raptor-tests --print-tests
We're assuming the 'raptor-tests' command is 'raptor-test' and we're executing it for you.
Raptor Tests Available for Firefox Desktop
==========================================
raptor-assorted-dom
type: benchmark
Stephens-MacBook-Pro:mozilla-source stephendonner$ cd mozilla-central
Stephens-MacBook-Pro:mozilla-central stephendonner$ ./mach raptor-test --test raptor-speedometer --app=geckoview --binary="org.mozilla.geckoview_example"
Error running mach:
['raptor-test', '--test', 'raptor-speedometer', '--app=geckoview', '--binary=org.mozilla.geckoview_example']
The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.
You should consider filing a bug for this issue.
from dataclasses import asdict, dataclass
import json
import os
import sys
from jsonschema import validate
# import requests
@dataclass
Timing Specs Used (incl. which Level)
* Navigation Timing API
* Performance Navigation Timing API
** https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming
Metrics
* Using:
** fetchStart:
*** https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/fetchStart
@davehunt
davehunt / wpt_user_agent.py
Created November 8, 2018 09:48
Show location and user agents from WebPageTest results
import json
with open("/Users/dhunt/Desktop/wpt.json") as f:
data = json.load(f)
for test in data:
location = test["data"]["location"]
request_headers = test["data"]["runs"]["1"]["firstView"]["requests"][0]["headers"]["request"]
user_agent = next(filter(lambda x: x.startswith("User-Agent:"), request_headers))
print(f"location: {location}")
print(f"- user-agent: {user_agent}")

WebPageTest

Custom Metrics tab:

[timeToDOMContentFlushed]
return window.performance.timing.timeToDOMContentFlushed;

Script tab:

driver = webdriver.Firefox()
driver.get('https://pypi.org')
with driver.context('chrome'):
driver.find_element_by_css_selector('image#pageActionButton').click()
driver.find_element_by_css_selector('#pageAction-panel-screenshots').click()
with driver.context(driver.CONTEXT_CONTENT):
sleep(2)
onboarding = driver.find_element_by_id('firefox-screenshots-onboarding-iframe')
driver.switch_to.frame(onboarding)
driver.find_element_by_id('skip').click()