-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from YusukeIwaki/emulateNetworkConditions
add Page#emulateNetworkConditions
- Loading branch information
Showing
9 changed files
with
110 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require_relative './device' | ||
|
||
Puppeteer::DEVICES = Hash[ | ||
[ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Puppeteer::NetworkCondition | ||
# @param download [Number] Download speed (bytes/s) | ||
# @param upload [Number] Upload speed (bytes/s) | ||
# @param latency [Number] Latency (ms) | ||
def initialize(download:, upload:, latency:) | ||
@download = download | ||
@upload = upload | ||
@latency = latency | ||
end | ||
|
||
attr_reader :download, :upload, :latency | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require_relative './network_condition' | ||
|
||
Puppeteer::NETWORK_CONDITIONS = { | ||
'Slow 3G' => Puppeteer::NetworkCondition.new( | ||
download: ((500 * 1000) / 8) * 0.8, | ||
upload: ((500 * 1000) / 8) * 0.8, | ||
latency: 400 * 5, | ||
), | ||
'Fast 3G' => Puppeteer::NetworkCondition.new( | ||
download: ((1.6 * 1000 * 1000) / 8) * 0.9, | ||
upload: ((750 * 1000) / 8) * 0.9, | ||
latency: 150 * 3.75, | ||
), | ||
} | ||
|
||
module Puppeteer::NetworkConditions | ||
module_function def slow_3g | ||
Puppeteer::NETWORK_CONDITIONS['Slow 3G'] | ||
end | ||
|
||
module_function def fast_3g | ||
Puppeteer::NETWORK_CONDITIONS['Fast 3G'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters