-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bei Zhang
committed
Sep 16, 2014
1 parent
58e6656
commit 2b7b246
Showing
3 changed files
with
36 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head lang="en"> | ||
<meta charset="UTF-8"> | ||
<title>Detect callPhantom</title> | ||
</head> | ||
<body> | ||
<script> | ||
if (window.callPhantom || window._phantom) { | ||
console.log("PhantomJS environment detected."); | ||
} else { | ||
console.log("PhantomJS environment not detected."); | ||
} | ||
</script> | ||
</body> | ||
</html> |
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,20 @@ | ||
page.onInitialized = function () { | ||
page.evaluate(function () { | ||
var p = window.callPhantom; | ||
delete window._phantom; | ||
delete window.callPhantom; | ||
Object.defineProperty(window, "myCallPhantom", { | ||
get: function () { | ||
return p; | ||
}, | ||
set: function () { | ||
}, enumerable: false}); | ||
setTimeout(function () { | ||
window.myCallPhantom(); | ||
}, 1000); | ||
}); | ||
}; | ||
|
||
page.onCallback = function (obj) { | ||
console.log('profit!'); | ||
}; |
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