-
-
Save nurrony/f8e0d43faf78f4832df23cc6e3579271 to your computer and use it in GitHub Desktop.
Try to overwrite window.document.referrer from within phantomjs / onInitialized
This file contains hidden or 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
| var page = require('webpage').create(); | |
| page.onConsoleMessage = function (msg) { | |
| console.log('From Page Console: '+msg); | |
| }; | |
| page.onInitialized = function() { | |
| page.evaluate(function () { | |
| "use strict"; | |
| //The Referrer we want to set | |
| var myReferrer = 'http://referrer.example.com'; | |
| function showInfo(){ | |
| console.log("window.document.referrer is: '" + window.document.referrer + "' of type: '" + typeof window.document.referrer+"'"); | |
| }; | |
| //Before | |
| console.log("Status Quo"); | |
| showInfo(); | |
| // Trying to delete the property | |
| console.log("Deleting document.referrer"); | |
| delete window.document.referrer; | |
| showInfo(); | |
| // Manually setting the referrer | |
| console.log('Manual overwrite') | |
| window.document.referrer = myReferrer; | |
| showInfo(); | |
| // defining a getter method | |
| console.log('testing defineGetter'); | |
| window.document.__defineGetter__('referrer', function () { | |
| return myReferrer; | |
| }); | |
| showInfo(); | |
| }); | |
| } | |
| page.onLoadFinished = function (status) { | |
| exit(); | |
| }; | |
| page.open('http://example.com'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment