Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
LunarBot
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Max
LunarBot
Commits
2317f78a
Commit
2317f78a
authored
Jun 02, 2018
by
maxlunar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing trash from phantomjs.
parent
460597c8
Changes
45
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
45 changed files
with
0 additions
and
3263 deletions
+0
-3263
core/webdriver/phantomjs/examples/arguments.js
core/webdriver/phantomjs/examples/arguments.js
+0
-10
core/webdriver/phantomjs/examples/child_process-examples.js
core/webdriver/phantomjs/examples/child_process-examples.js
+0
-28
core/webdriver/phantomjs/examples/colorwheel.js
core/webdriver/phantomjs/examples/colorwheel.js
+0
-52
core/webdriver/phantomjs/examples/countdown.js
core/webdriver/phantomjs/examples/countdown.js
+0
-10
core/webdriver/phantomjs/examples/detectsniff.js
core/webdriver/phantomjs/examples/detectsniff.js
+0
-60
core/webdriver/phantomjs/examples/echoToFile.js
core/webdriver/phantomjs/examples/echoToFile.js
+0
-24
core/webdriver/phantomjs/examples/features.js
core/webdriver/phantomjs/examples/features.js
+0
-30
core/webdriver/phantomjs/examples/fibo.js
core/webdriver/phantomjs/examples/fibo.js
+0
-10
core/webdriver/phantomjs/examples/hello.js
core/webdriver/phantomjs/examples/hello.js
+0
-3
core/webdriver/phantomjs/examples/injectme.js
core/webdriver/phantomjs/examples/injectme.js
+0
-26
core/webdriver/phantomjs/examples/loadspeed.js
core/webdriver/phantomjs/examples/loadspeed.js
+0
-24
core/webdriver/phantomjs/examples/loadurlwithoutcss.js
core/webdriver/phantomjs/examples/loadurlwithoutcss.js
+0
-26
core/webdriver/phantomjs/examples/modernizr.js
core/webdriver/phantomjs/examples/modernizr.js
+0
-1406
core/webdriver/phantomjs/examples/module.js
core/webdriver/phantomjs/examples/module.js
+0
-5
core/webdriver/phantomjs/examples/netlog.js
core/webdriver/phantomjs/examples/netlog.js
+0
-26
core/webdriver/phantomjs/examples/netsniff.js
core/webdriver/phantomjs/examples/netsniff.js
+0
-144
core/webdriver/phantomjs/examples/openurlwithproxy.js
core/webdriver/phantomjs/examples/openurlwithproxy.js
+0
-25
core/webdriver/phantomjs/examples/outputEncoding.js
core/webdriver/phantomjs/examples/outputEncoding.js
+0
-17
core/webdriver/phantomjs/examples/page_events.js
core/webdriver/phantomjs/examples/page_events.js
+0
-147
core/webdriver/phantomjs/examples/pagecallback.js
core/webdriver/phantomjs/examples/pagecallback.js
+0
-18
core/webdriver/phantomjs/examples/phantomwebintro.js
core/webdriver/phantomjs/examples/phantomwebintro.js
+0
-21
core/webdriver/phantomjs/examples/post.js
core/webdriver/phantomjs/examples/post.js
+0
-15
core/webdriver/phantomjs/examples/postjson.js
core/webdriver/phantomjs/examples/postjson.js
+0
-19
core/webdriver/phantomjs/examples/postserver.js
core/webdriver/phantomjs/examples/postserver.js
+0
-35
core/webdriver/phantomjs/examples/printenv.js
core/webdriver/phantomjs/examples/printenv.js
+0
-10
core/webdriver/phantomjs/examples/printheaderfooter.js
core/webdriver/phantomjs/examples/printheaderfooter.js
+0
-90
core/webdriver/phantomjs/examples/printmargins.js
core/webdriver/phantomjs/examples/printmargins.js
+0
-36
core/webdriver/phantomjs/examples/rasterize.js
core/webdriver/phantomjs/examples/rasterize.js
+0
-49
core/webdriver/phantomjs/examples/render_multi_url.js
core/webdriver/phantomjs/examples/render_multi_url.js
+0
-74
core/webdriver/phantomjs/examples/responsive-screenshot.js
core/webdriver/phantomjs/examples/responsive-screenshot.js
+0
-181
core/webdriver/phantomjs/examples/run-jasmine.js
core/webdriver/phantomjs/examples/run-jasmine.js
+0
-92
core/webdriver/phantomjs/examples/run-jasmine2.js
core/webdriver/phantomjs/examples/run-jasmine2.js
+0
-94
core/webdriver/phantomjs/examples/run-qunit.js
core/webdriver/phantomjs/examples/run-qunit.js
+0
-77
core/webdriver/phantomjs/examples/scandir.js
core/webdriver/phantomjs/examples/scandir.js
+0
-24
core/webdriver/phantomjs/examples/server.js
core/webdriver/phantomjs/examples/server.js
+0
-44
core/webdriver/phantomjs/examples/serverkeepalive.js
core/webdriver/phantomjs/examples/serverkeepalive.js
+0
-35
core/webdriver/phantomjs/examples/simpleserver.js
core/webdriver/phantomjs/examples/simpleserver.js
+0
-43
core/webdriver/phantomjs/examples/sleepsort.js
core/webdriver/phantomjs/examples/sleepsort.js
+0
-27
core/webdriver/phantomjs/examples/stdin-stdout-stderr.js
core/webdriver/phantomjs/examples/stdin-stdout-stderr.js
+0
-19
core/webdriver/phantomjs/examples/universe.js
core/webdriver/phantomjs/examples/universe.js
+0
-10
core/webdriver/phantomjs/examples/unrandomize.js
core/webdriver/phantomjs/examples/unrandomize.js
+0
-25
core/webdriver/phantomjs/examples/useragent.js
core/webdriver/phantomjs/examples/useragent.js
+0
-15
core/webdriver/phantomjs/examples/version.js
core/webdriver/phantomjs/examples/version.js
+0
-6
core/webdriver/phantomjs/examples/waitfor.js
core/webdriver/phantomjs/examples/waitfor.js
+0
-58
core/webdriver/phantomjs/examples/walk_through_frames.js
core/webdriver/phantomjs/examples/walk_through_frames.js
+0
-73
No files found.
core/webdriver/phantomjs/examples/arguments.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
system
=
require
(
'
system
'
);
if
(
system
.
args
.
length
===
1
)
{
console
.
log
(
'
Try to pass some args when invoking this script!
'
);
}
else
{
system
.
args
.
forEach
(
function
(
arg
,
i
)
{
console
.
log
(
i
+
'
:
'
+
arg
);
});
}
phantom
.
exit
();
core/webdriver/phantomjs/examples/child_process-examples.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
spawn
=
require
(
"
child_process
"
).
spawn
var
execFile
=
require
(
"
child_process
"
).
execFile
var
child
=
spawn
(
"
ls
"
,
[
"
-lF
"
,
"
/rooot
"
])
child
.
stdout
.
on
(
"
data
"
,
function
(
data
)
{
console
.
log
(
"
spawnSTDOUT:
"
,
JSON
.
stringify
(
data
))
})
child
.
stderr
.
on
(
"
data
"
,
function
(
data
)
{
console
.
log
(
"
spawnSTDERR:
"
,
JSON
.
stringify
(
data
))
})
child
.
on
(
"
exit
"
,
function
(
code
)
{
console
.
log
(
"
spawnEXIT:
"
,
code
)
})
//child.kill("SIGKILL")
execFile
(
"
ls
"
,
[
"
-lF
"
,
"
/usr
"
],
null
,
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
"
execFileSTDOUT:
"
,
JSON
.
stringify
(
stdout
))
console
.
log
(
"
execFileSTDERR:
"
,
JSON
.
stringify
(
stderr
))
})
setTimeout
(
function
()
{
phantom
.
exit
(
0
)
},
2000
)
core/webdriver/phantomjs/examples/colorwheel.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
page
=
require
(
'
webpage
'
).
create
();
page
.
viewportSize
=
{
width
:
400
,
height
:
400
};
page
.
content
=
'
<html><body><canvas id="surface"></canvas></body></html>
'
;
page
.
evaluate
(
function
()
{
var
el
=
document
.
getElementById
(
'
surface
'
),
context
=
el
.
getContext
(
'
2d
'
),
width
=
window
.
innerWidth
,
height
=
window
.
innerHeight
,
cx
=
width
/
2
,
cy
=
height
/
2
,
radius
=
width
/
2.3
,
imageData
,
pixels
,
hue
,
sat
,
value
,
i
=
0
,
x
,
y
,
rx
,
ry
,
d
,
f
,
g
,
p
,
u
,
v
,
w
,
rgb
;
el
.
width
=
width
;
el
.
height
=
height
;
imageData
=
context
.
createImageData
(
width
,
height
);
pixels
=
imageData
.
data
;
for
(
y
=
0
;
y
<
height
;
y
=
y
+
1
)
{
for
(
x
=
0
;
x
<
width
;
x
=
x
+
1
,
i
=
i
+
4
)
{
rx
=
x
-
cx
;
ry
=
y
-
cy
;
d
=
rx
*
rx
+
ry
*
ry
;
if
(
d
<
radius
*
radius
)
{
hue
=
6
*
(
Math
.
atan2
(
ry
,
rx
)
+
Math
.
PI
)
/
(
2
*
Math
.
PI
);
sat
=
Math
.
sqrt
(
d
)
/
radius
;
g
=
Math
.
floor
(
hue
);
f
=
hue
-
g
;
u
=
255
*
(
1
-
sat
);
v
=
255
*
(
1
-
sat
*
f
);
w
=
255
*
(
1
-
sat
*
(
1
-
f
));
pixels
[
i
]
=
[
255
,
v
,
u
,
u
,
w
,
255
,
255
][
g
];
pixels
[
i
+
1
]
=
[
w
,
255
,
255
,
v
,
u
,
u
,
w
][
g
];
pixels
[
i
+
2
]
=
[
u
,
u
,
w
,
255
,
255
,
v
,
u
][
g
];
pixels
[
i
+
3
]
=
255
;
}
}
}
context
.
putImageData
(
imageData
,
0
,
0
);
document
.
body
.
style
.
backgroundColor
=
'
white
'
;
document
.
body
.
style
.
margin
=
'
0px
'
;
});
page
.
render
(
'
colorwheel.png
'
);
phantom
.
exit
();
core/webdriver/phantomjs/examples/countdown.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
t
=
10
,
interval
=
setInterval
(
function
(){
if
(
t
>
0
)
{
console
.
log
(
t
--
);
}
else
{
console
.
log
(
"
BLAST OFF!
"
);
phantom
.
exit
();
}
},
1000
);
core/webdriver/phantomjs/examples/detectsniff.js
deleted
100644 → 0
View file @
460597c8
// Detect if a web page sniffs the user agent or not.
"
use strict
"
;
var
page
=
require
(
'
webpage
'
).
create
(),
system
=
require
(
'
system
'
),
sniffed
,
address
;
page
.
onInitialized
=
function
()
{
page
.
evaluate
(
function
()
{
(
function
()
{
var
userAgent
=
window
.
navigator
.
userAgent
,
platform
=
window
.
navigator
.
platform
;
window
.
navigator
=
{
appCodeName
:
'
Mozilla
'
,
appName
:
'
Netscape
'
,
cookieEnabled
:
false
,
sniffed
:
false
};
window
.
navigator
.
__defineGetter__
(
'
userAgent
'
,
function
()
{
window
.
navigator
.
sniffed
=
true
;
return
userAgent
;
});
window
.
navigator
.
__defineGetter__
(
'
platform
'
,
function
()
{
window
.
navigator
.
sniffed
=
true
;
return
platform
;
});
})();
});
};
if
(
system
.
args
.
length
===
1
)
{
console
.
log
(
'
Usage: detectsniff.js <some URL>
'
);
phantom
.
exit
(
1
);
}
else
{
address
=
system
.
args
[
1
];
console
.
log
(
'
Checking
'
+
address
+
'
...
'
);
page
.
open
(
address
,
function
(
status
)
{
if
(
status
!==
'
success
'
)
{
console
.
log
(
'
FAIL to load the address
'
);
phantom
.
exit
();
}
else
{
window
.
setTimeout
(
function
()
{
sniffed
=
page
.
evaluate
(
function
()
{
return
navigator
.
sniffed
;
});
if
(
sniffed
)
{
console
.
log
(
'
The page tried to sniff the user agent.
'
);
}
else
{
console
.
log
(
'
The page did not try to sniff the user agent.
'
);
}
phantom
.
exit
();
},
1500
);
}
});
}
core/webdriver/phantomjs/examples/echoToFile.js
deleted
100644 → 0
View file @
460597c8
// echoToFile.js - Write in a given file all the parameters passed on the CLI
"
use strict
"
;
var
fs
=
require
(
'
fs
'
),
system
=
require
(
'
system
'
);
if
(
system
.
args
.
length
<
3
)
{
console
.
log
(
"
Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>
"
);
phantom
.
exit
(
1
);
}
else
{
var
content
=
''
,
f
=
null
,
i
;
for
(
i
=
2
;
i
<
system
.
args
.
length
;
++
i
)
{
content
+=
system
.
args
[
i
]
+
(
i
===
system
.
args
.
length
-
1
?
''
:
'
'
);
}
try
{
fs
.
write
(
system
.
args
[
1
],
content
,
'
w
'
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
phantom
.
exit
();
}
core/webdriver/phantomjs/examples/features.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
feature
,
supported
=
[],
unsupported
=
[];
phantom
.
injectJs
(
'
modernizr.js
'
);
console
.
log
(
'
Detected features (using Modernizr
'
+
Modernizr
.
_version
+
'
):
'
);
for
(
feature
in
Modernizr
)
{
if
(
Modernizr
.
hasOwnProperty
(
feature
))
{
if
(
feature
[
0
]
!==
'
_
'
&&
typeof
Modernizr
[
feature
]
!==
'
function
'
&&
feature
!==
'
input
'
&&
feature
!==
'
inputtypes
'
)
{
if
(
Modernizr
[
feature
])
{
supported
.
push
(
feature
);
}
else
{
unsupported
.
push
(
feature
);
}
}
}
}
console
.
log
(
''
);
console
.
log
(
'
Supported:
'
);
supported
.
forEach
(
function
(
e
)
{
console
.
log
(
'
'
+
e
);
});
console
.
log
(
''
);
console
.
log
(
'
Not supported:
'
);
unsupported
.
forEach
(
function
(
e
)
{
console
.
log
(
'
'
+
e
);
});
phantom
.
exit
();
core/webdriver/phantomjs/examples/fibo.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
fibs
=
[
0
,
1
];
var
ticker
=
window
.
setInterval
(
function
()
{
console
.
log
(
fibs
[
fibs
.
length
-
1
]);
fibs
.
push
(
fibs
[
fibs
.
length
-
1
]
+
fibs
[
fibs
.
length
-
2
]);
if
(
fibs
.
length
>
10
)
{
window
.
clearInterval
(
ticker
);
phantom
.
exit
();
}
},
300
);
core/webdriver/phantomjs/examples/hello.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
console
.
log
(
'
Hello, world!
'
);
phantom
.
exit
();
core/webdriver/phantomjs/examples/injectme.js
deleted
100644 → 0
View file @
460597c8
// Use 'page.injectJs()' to load the script itself in the Page context
"
use strict
"
;
if
(
typeof
(
phantom
)
!==
"
undefined
"
)
{
var
page
=
require
(
'
webpage
'
).
create
();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page
.
onConsoleMessage
=
function
(
msg
)
{
console
.
log
(
msg
);
};
page
.
onAlert
=
function
(
msg
)
{
console
.
log
(
msg
);
};
console
.
log
(
"
* Script running in the Phantom context.
"
);
console
.
log
(
"
* Script will 'inject' itself in a page...
"
);
page
.
open
(
"
about:blank
"
,
function
(
status
)
{
if
(
status
===
"
success
"
)
{
console
.
log
(
page
.
injectJs
(
"
injectme.js
"
)
?
"
... done injecting itself!
"
:
"
... fail! Check the $PWD?!
"
);
}
phantom
.
exit
();
});
}
else
{
alert
(
"
* Script running in the Page context.
"
);
}
core/webdriver/phantomjs/examples/loadspeed.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
page
=
require
(
'
webpage
'
).
create
(),
system
=
require
(
'
system
'
),
t
,
address
;
if
(
system
.
args
.
length
===
1
)
{
console
.
log
(
'
Usage: loadspeed.js <some URL>
'
);
phantom
.
exit
(
1
);
}
else
{
t
=
Date
.
now
();
address
=
system
.
args
[
1
];
page
.
open
(
address
,
function
(
status
)
{
if
(
status
!==
'
success
'
)
{
console
.
log
(
'
FAIL to load the address
'
);
}
else
{
t
=
Date
.
now
()
-
t
;
console
.
log
(
'
Page title is
'
+
page
.
evaluate
(
function
()
{
return
document
.
title
;
}));
console
.
log
(
'
Loading time
'
+
t
+
'
msec
'
);
}
phantom
.
exit
();
});
}
core/webdriver/phantomjs/examples/loadurlwithoutcss.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
page
=
require
(
'
webpage
'
).
create
(),
system
=
require
(
'
system
'
);
if
(
system
.
args
.
length
<
2
)
{
console
.
log
(
'
Usage: loadurlwithoutcss.js URL
'
);
phantom
.
exit
();
}
var
address
=
system
.
args
[
1
];
page
.
onResourceRequested
=
function
(
requestData
,
request
)
{
if
((
/http:
\/\/
.+
?\.
css/gi
).
test
(
requestData
[
'
url
'
])
||
requestData
.
headers
[
'
Content-Type
'
]
==
'
text/css
'
)
{
console
.
log
(
'
The url of the request is matching. Aborting:
'
+
requestData
[
'
url
'
]);
request
.
abort
();
}
};
page
.
open
(
address
,
function
(
status
)
{
if
(
status
===
'
success
'
)
{
phantom
.
exit
();
}
else
{
console
.
log
(
'
Unable to load the address!
'
);
phantom
.
exit
();
}
});
\ No newline at end of file
core/webdriver/phantomjs/examples/modernizr.js
deleted
100644 → 0
View file @
460597c8
This diff is collapsed.
Click to expand it.
core/webdriver/phantomjs/examples/module.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
universe
=
require
(
'
./universe
'
);
universe
.
start
();
console
.
log
(
'
The answer is
'
+
universe
.
answer
);
phantom
.
exit
();
core/webdriver/phantomjs/examples/netlog.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
page
=
require
(
'
webpage
'
).
create
(),
system
=
require
(
'
system
'
),
address
;
if
(
system
.
args
.
length
===
1
)
{
console
.
log
(
'
Usage: netlog.js <some URL>
'
);
phantom
.
exit
(
1
);
}
else
{
address
=
system
.
args
[
1
];
page
.
onResourceRequested
=
function
(
req
)
{
console
.
log
(
'
requested:
'
+
JSON
.
stringify
(
req
,
undefined
,
4
));
};
page
.
onResourceReceived
=
function
(
res
)
{
console
.
log
(
'
received:
'
+
JSON
.
stringify
(
res
,
undefined
,
4
));
};
page
.
open
(
address
,
function
(
status
)
{
if
(
status
!==
'
success
'
)
{
console
.
log
(
'
FAIL to load the address
'
);
}
phantom
.
exit
();
});
}
core/webdriver/phantomjs/examples/netsniff.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
if
(
!
Date
.
prototype
.
toISOString
)
{
Date
.
prototype
.
toISOString
=
function
()
{
function
pad
(
n
)
{
return
n
<
10
?
'
0
'
+
n
:
n
;
}
function
ms
(
n
)
{
return
n
<
10
?
'
00
'
+
n
:
n
<
100
?
'
0
'
+
n
:
n
}
return
this
.
getFullYear
()
+
'
-
'
+
pad
(
this
.
getMonth
()
+
1
)
+
'
-
'
+
pad
(
this
.
getDate
())
+
'
T
'
+
pad
(
this
.
getHours
())
+
'
:
'
+
pad
(
this
.
getMinutes
())
+
'
:
'
+
pad
(
this
.
getSeconds
())
+
'
.
'
+
ms
(
this
.
getMilliseconds
())
+
'
Z
'
;
}
}
function
createHAR
(
address
,
title
,
startTime
,
resources
)
{
var
entries
=
[];
resources
.
forEach
(
function
(
resource
)
{
var
request
=
resource
.
request
,
startReply
=
resource
.
startReply
,
endReply
=
resource
.
endReply
;
if
(
!
request
||
!
startReply
||
!
endReply
)
{
return
;
}
// Exclude Data URI from HAR file because
// they aren't included in specification
if
(
request
.
url
.
match
(
/
(
^data:image
\/
.*
)
/i
))
{
return
;
}
entries
.
push
({
startedDateTime
:
request
.
time
.
toISOString
(),
time
:
endReply
.
time
-
request
.
time
,
request
:
{
method
:
request
.
method
,
url
:
request
.
url
,
httpVersion
:
"
HTTP/1.1
"
,
cookies
:
[],
headers
:
request
.
headers
,
queryString
:
[],
headersSize
:
-
1
,
bodySize
:
-
1
},
response
:
{
status
:
endReply
.
status
,
statusText
:
endReply
.
statusText
,
httpVersion
:
"
HTTP/1.1
"
,
cookies
:
[],
headers
:
endReply
.
headers
,
redirectURL
:
""
,
headersSize
:
-
1
,
bodySize
:
startReply
.
bodySize
,
content
:
{
size
:
startReply
.
bodySize
,
mimeType
:
endReply
.
contentType
}
},
cache
:
{},
timings
:
{
blocked
:
0
,
dns
:
-
1
,
connect
:
-
1
,
send
:
0
,
wait
:
startReply
.
time
-
request
.
time
,
receive
:
endReply
.
time
-
startReply
.
time
,
ssl
:
-
1
},
pageref
:
address
});
});
return
{
log
:
{
version
:
'
1.2
'
,
creator
:
{
name
:
"
PhantomJS
"
,
version
:
phantom
.
version
.
major
+
'
.
'
+
phantom
.
version
.
minor
+
'
.
'
+
phantom
.
version
.
patch
},
pages
:
[{
startedDateTime
:
startTime
.
toISOString
(),
id
:
address
,
title
:
title
,
pageTimings
:
{
onLoad
:
page
.
endTime
-
page
.
startTime
}
}],
entries
:
entries
}
};
}
var
page
=
require
(
'
webpage
'
).
create
(),
system
=
require
(
'
system
'
);
if
(
system
.
args
.
length
===
1
)
{
console
.
log
(
'
Usage: netsniff.js <some URL>
'
);
phantom
.
exit
(
1
);
}
else
{
page
.
address
=
system
.
args
[
1
];
page
.
resources
=
[];
page
.
onLoadStarted
=
function
()
{
page
.
startTime
=
new
Date
();
};
page
.
onResourceRequested
=
function
(
req
)
{
page
.
resources
[
req
.
id
]
=
{
request
:
req
,
startReply
:
null
,
endReply
:
null
};
};
page
.
onResourceReceived
=
function
(
res
)
{
if
(
res
.
stage
===
'
start
'
)
{
page
.
resources
[
res
.
id
].
startReply
=
res
;
}
if
(
res
.
stage
===
'
end
'
)
{
page
.
resources
[
res
.
id
].
endReply
=
res
;
}
};
page
.
open
(
page
.
address
,
function
(
status
)
{
var
har
;
if
(
status
!==
'
success
'
)
{
console
.
log
(
'
FAIL to load the address
'
);
phantom
.
exit
(
1
);
}
else
{
page
.
endTime
=
new
Date
();
page
.
title
=
page
.
evaluate
(
function
()
{
return
document
.
title
;
});
har
=
createHAR
(
page
.
address
,
page
.
title
,
page
.
startTime
,
page
.
resources
);
console
.
log
(
JSON
.
stringify
(
har
,
undefined
,
4
));
phantom
.
exit
();
}
});
}
core/webdriver/phantomjs/examples/openurlwithproxy.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
var
page
=
require
(
'
webpage
'
).
create
(),
system
=
require
(
'
system
'
),
host
,
port
,
address
;
if
(
system
.
args
.
length
<
4
)
{
console
.
log
(
'
Usage: openurlwithproxy.js <proxyHost> <proxyPort> <URL>
'
);
phantom
.
exit
(
1
);
}
else
{
host
=
system
.
args
[
1
];
port
=
system
.
args
[
2
];
address
=
system
.
args
[
3
];
phantom
.
setProxy
(
host
,
port
,
'
manual
'
,
''
,
''
);
page
.
open
(
address
,
function
(
status
)
{
if
(
status
!==
'
success
'
)
{
console
.
log
(
'
FAIL to load the address "
'
+
address
+
'
" using proxy "
'
+
host
+
'
:
'
+
port
+
'
"
'
);
}
else
{
console
.
log
(
'
Page title is
'
+
page
.
evaluate
(
function
()
{
return
document
.
title
;
}));
}
phantom
.
exit
();
});
}
core/webdriver/phantomjs/examples/outputEncoding.js
deleted
100644 → 0
View file @
460597c8
"
use strict
"
;
function
helloWorld
()
{
console
.
log
(
phantom
.
outputEncoding
+
"
: こんにちは、世界!
"
);
}
console
.
log
(
"
Using default encoding...
"
);
helloWorld
();
console
.
log
(
"
\n
Using other encodings...
"
);
var
encodings
=
[
"
euc-jp
"
,
"
sjis
"
,
"
utf8
"
,
"
System
"
];
for
(
var
i
=
0
;
i
<
encodings
.
length
;
i
++
)
{
phantom
.
outputEncoding
=
encodings
[
i
];
helloWorld
();
}
phantom
.
exit
()
core/webdriver/phantomjs/examples/page_events.js
deleted
100644 → 0
View file @
460597c8
// The purpose of this is to show how and when events fire, considering 5 steps
// happening as follows:
//
// 1. Load URL
// 2. Load same URL, but adding an internal FRAGMENT to it
// 3. Click on an internal Link, that points to another internal FRAGMENT
// 4. Click on an external Link, that will send the page somewhere else
// 5. Close page
//
// Take particular care when going through the output, to understand when
// things happen (and in which order). Particularly, notice what DOESN'T
// happen during step 3.
//
// If invoked with "-v" it will print out the Page Resources as they are
// Requested and Received.
//
// NOTE.1: The "onConsoleMessage/onAlert/onPrompt/onConfirm" events are
// registered but not used here. This is left for you to have fun with.
// NOTE.2: This script is not here to teach you ANY JavaScript. It's aweful!
// NOTE.3: Main audience for this are people new to PhantomJS.
"
use strict
"
;
var
sys
=
require
(
"
system
"
),
page
=
require
(
"
webpage
"
).
create
(),
logResources
=
false
,
step1url
=
"
http://en.wikipedia.org/wiki/DOM_events
"
,
step2url
=
"
http://en.wikipedia.org/wiki/DOM_events#Event_flow
"
;
if
(
sys
.
args
.
length
>
1
&&
sys
.
args
[
1
]
===
"
-v
"
)
{
logResources
=
true
;
}
function
printArgs
()
{
var
i
,
ilen
;
for
(
i
=
0
,
ilen
=
arguments
.
length
;
i
<
ilen
;
++
i
)
{
console
.
log
(
"
arguments[
"
+
i
+
"
] =
"
+
JSON
.
stringify
(
arguments
[
i
]));
}
console
.
log
(
""
);
}
////////////////////////////////////////////////////////////////////////////////
page
.
onInitialized
=
function
()
{
console
.
log
(
"
page.onInitialized
"
);
printArgs
.
apply
(
this
,
arguments
);
};
page
.
onLoadStarted
=
function
()
{
console
.
log
(
"
page.onLoadStarted
"
);
printArgs
.
apply
(
this
,
arguments
);
};
page
.
onLoadFinished
=
function
()
{
console
.
log
(
"
page.onLoadFinished
"
);
printArgs
.
apply
(
this
,
arguments
);
};
page
.
onUrlChanged
=
function
()
{
console
.
log
(
"
page.onUrlChanged
"
);
printArgs
.
apply
(
this
,
arguments
);
};
page
.
onNavigationRequested
=
function
()
{
console
.
log
(
"
page.onNavigationRequested
"
);
printArgs
.
apply
(
this
,
arguments
);
};
page
.
onRepaintRequested
=
function
()
{
console
.
log
(
"
page.onRepaintRequested
"
);
printArgs
.
apply
(
this
,
arguments
);
};
if
(
logResources
===
true
)
{
page
.
onResourceRequested
=
function
()
{
console
.
log
(
"
page.onResourceRequested
"
);
printArgs
.
apply
(
this
,
arguments
);
};
page
.
onResourceReceived
=
function
()
{
console
.
log
(
"
page.onResourceReceived
"
);
printArgs
.
apply
(
this
,
arguments
);
};
}
page
.
onClosing
=
function
()
{
console
.
log
(
"
page.onClosing
"
);
printArgs
.
apply
(
this
,
arguments
);
};
// window.console.log(msg);
page
.
onConsoleMessage
=
function
()
{
console
.
log
(
"
page.onConsoleMessage
"
);
printArgs
.
apply
(
this
,
arguments
);
};
// window.alert(msg);
page
.
onAlert
=
function
()
{
console
.
log
(
"
page.onAlert
"
);
printArgs
.
apply
(
this
,
arguments
);
};
// var confirmed = window.confirm(msg);
page
.
onConfirm
=
function
()
{
console
.
log
(
"
page.onConfirm
"
);
printArgs
.
apply
(
this
,
arguments
);
};
// var user_value = window.prompt(msg, default_value);
page
.
onPrompt
=
function
()
{
console
.
log
(
"
page.onPrompt
"
);
printArgs
.
apply
(
this
,
arguments
);
};
////////////////////////////////////////////////////////////////////////////////
setTimeout
(
function
()
{
console
.
log
(
""
);
console
.
log
(
"
### STEP 1: Load '
"
+
step1url
+
"
'
"
);
page
.
open
(
step1url
);
},
0
);
setTimeout
(
function
()
{
console
.
log
(
""
);
console
.
log
(
"
### STEP 2: Load '
"
+
step2url
+
"
' (load same URL plus FRAGMENT)
"
);
page
.
open
(
step2url
);
},
5000
);
setTimeout
(
function
()
{
console
.
log
(
""
);
console
.
log
(
"
### STEP 3: Click on page internal link (aka FRAGMENT)
"
);
page
.
evaluate
(
function
()
{
var
ev
=
document
.
createEvent
(
"
MouseEvents
"
);
ev
.
initEvent
(
"
click
"
,
true
,
true
);
document
.
querySelector
(
"
a[href='#Event_object']
"
).
dispatchEvent
(
ev
);
});