source: other-projects/FileTransfer-WebSocketPair/Themes/themebuilder/bin/phantomjs-1.9.2-macosx/examples/detectsniff.coffee@ 31525

Last change on this file since 31525 was 31525, checked in by ak19, 7 years ago

Nathan provided more stuff: Themes folder contains Sencha's Themebuilder which generates GXT Themes. It includes the .theme and generated .jar files for the project theme.

File size: 1.1 KB
Line 
1page = require('webpage').create()
2system = require 'system'
3
4page.onInitialized = ->
5 page.evaluate ->
6 userAgent = window.navigator.userAgent
7 platform = window.navigator.platform
8 window.navigator =
9 appCodeName: 'Mozilla'
10 appName: 'Netscape'
11 cookieEnabled: false
12 sniffed: false
13
14 window.navigator.__defineGetter__ 'userAgent', ->
15 window.navigator.sniffed = true
16 userAgent
17
18 window.navigator.__defineGetter__ 'platform', ->
19 window.navigator.sniffed = true
20 platform
21
22if system.args.length is 1
23 console.log 'Usage: detectsniff.coffee <some URL>'
24 phantom.exit 1
25else
26 address = system.args[1]
27 console.log 'Checking ' + address + '...'
28 page.open address, (status) ->
29 if status isnt 'success'
30 console.log 'FAIL to load the address'
31 phantom.exit()
32 else
33 window.setTimeout ->
34 sniffed = page.evaluate(->
35 navigator.sniffed
36 )
37 if sniffed
38 console.log 'The page tried to sniff the user agent.'
39 else
40 console.log 'The page did not try to sniff the user agent.'
41 phantom.exit()
42 , 1500
Note: See TracBrowser for help on using the repository browser.