Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for requestAnimationFrame() #115

Merged
merged 1 commit into from
Sep 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified builds/current/0-0-28.zip
Binary file not shown.
1 change: 1 addition & 0 deletions doc/en-US/guides/how-it-works/interception.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Original settings:
```json
{
"WebAPIs": {
"requestAnimationFrame": true,
"XMLHttpRequest.open": true,
"XMLHttpRequest.send": true,
"geo.getCurrentPosition": true,
Expand Down
1 change: 1 addition & 0 deletions doc/en-US/guides/how-it-works/what-is-detected.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Some JavaScripts are reported with a different nomenclature to get closer to the
| Window.setInterval (execution) | setInterval.call | `setInterval(function() { /*call*/ }, 1000)` |
| Window.setTimeout | setTimeout | `setTimeout(function() { }, 1000)` |
| Window.setTimeout (execution) | setTimeout.call | `setTimeout(function() { /*call*/ }, 1000)` |
| Window.requestAnimationFrame | requestAnimationFrame | `requestAnimationFrame(function() { /*call*/ })` |
| WebSocket.send | WebSocket.send | `(new WebSocket('ws://host:80')).send('hello')` |
| XMLHttpRequest.open | XMLHttpRequest.open | `(new XMLHttpRequest()).open('GET', 'f.txt')` |
| XMLHttpRequest.send | XMLHttpRequest.send | `(new XMLHttpRequest()).open('GET', 'f.txt').send()` |
Expand Down
6 changes: 6 additions & 0 deletions html/demos/detections/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
<br><br>

<div id="userAgent" class="small-demo-box">navigator.userAgent</div>

<div id="requestAnimationFrame" class="small-demo-box">requestAnimationFrame()</div>
</div>

<script type="text/javascript">
Expand All @@ -107,6 +109,10 @@

(function() { setTimeout(function() {

window.requestAnimationFrame(function() {
document.getElementById('requestAnimationFrame').innerHTML = 'requestAnimationFrame():<br>animation executed!'
});

document.getElementById('userAgent').innerHTML = 'navigator.userAgent:<br>' + window.navigator.userAgent.slice(0, 24);
document.getElementById('userAgent').setAttribute('title', window.navigator.userAgent);

Expand Down
2 changes: 2 additions & 0 deletions js/content/interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ if(should_luminous_run) {
// interceptors/xml_http_request/open.js
// interceptors/xml_http_request/send.js

// interceptors/window/request_animation_frame.js

// /load_injectors
}
}
32 changes: 32 additions & 0 deletions js/content/interceptors/window/request_animation_frame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var original_window_requestAnimationFrame = window.requestAnimationFrame;

window.requestAnimationFrame = function(callback) {
var super_this = this;

if(get_options()['injection_disabled']) {
return original_window_requestAnimationFrame.call(super_this, callback);
} else {
if(!is_allowed('WebAPIs', 'requestAnimationFrame')) {
increment_counter('WebAPIs', 'requestAnimationFrame', false, super_this, callback, 0);

// A long integer value, the request id, that uniquely identifies the
// entry in the callback list. This is a non-zero value, but you may
// not make any other assumptions about its value. You can pass this
// value to window.cancelAnimationFrame() to cancel the refresh
// callback request.
// https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
return 1;
} else {
var timer = performance.now();

var execution_return = original_window_requestAnimationFrame.call(super_this, callback);

increment_counter(
'WebAPIs', 'requestAnimationFrame', true, super_this, callback, 0,
performance.now() - timer
);

return execution_return;
}
}
}
3 changes: 2 additions & 1 deletion js/helpers/code_names.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var common_webapis = [
'setInterval', 'setInterval.call',
'setTimeout', 'setTimeout.call',
'WebSocket.send',
'XMLHttpRequest.open', 'XMLHttpRequest.send'
'XMLHttpRequest.open', 'XMLHttpRequest.send',
'requestAnimationFrame'
];

var common_events = [
Expand Down
1 change: 1 addition & 0 deletions js/logs/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ devtools_tab_id.onMessage.addListener(function(tab) {

var default_filter_out = [
'setInterval', 'setTimeout',
'requestAnimationFrame',
'handleEvent.message',
'handleEvent.timeupdate',
'handleEvent.progress',
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"js/content/interceptors/schedulers/set_timeout.js",
"js/content/interceptors/web_socket/send.js",
"js/content/interceptors/xml_http_request/open.js",
"js/content/interceptors/xml_http_request/send.js"
"js/content/interceptors/xml_http_request/send.js",
"js/content/interceptors/window/request_animation_frame.js"
]
}