1 // Detect if a web page sniffs the user agent or not.
3 var page = require('webpage').create(),
4 system = require('system'),
8 page.onInitialized = function () {
9 page.evaluate(function () {
12 var userAgent = window.navigator.userAgent,
13 platform = window.navigator.platform;
16 appCodeName: 'Mozilla',
22 window.navigator.__defineGetter__('userAgent', function () {
23 window.navigator.sniffed = true;
27 window.navigator.__defineGetter__('platform', function () {
28 window.navigator.sniffed = true;
35 if (system.args.length === 1) {
36 console.log('Usage: detectsniff.js <some URL>');
39 address = system.args[1];
40 console.log('Checking ' + address + '...');
41 page.open(address, function (status) {
42 if (status !== 'success') {
43 console.log('FAIL to load the address');
46 window.setTimeout(function () {
47 sniffed = page.evaluate(function () {
48 return navigator.sniffed;
51 console.log('The page tried to sniff the user agent.');
53 console.log('The page did not try to sniff the user agent.');