-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PhantomJS: Script error on Object.defineProperty for DOM element and Event objects #823
Comments
Maybe we should try ianstormtaylor/create-event#9 solution? |
I tried this dark magic and got that it works only for attribute properties. Step to reproduce:
Test.js/*Dom element*/ /*Worked*/
console.log('Dom element');
console.log('document.body.attributes.length before redefine:', document.body.attributes.length);
document.body.attributes.constructor.prototype.__defineGetter__('length', function () {return 1000; }); //work
console.log('document.body.attributes.constructor.prototype.__defineGetter__:', document.body.attributes.length);
document.body.attributes.__defineGetter__('length', function () { return 2000; });// don't work
console.log('document.body.attributes.__defineGetter__:',document.body.attributes.length);
/*Event*/
console.log('Event');
var evt = document.createEvent('StorageEvent');
evt.initStorageEvent('storage',false,false,'key','oldValue','newValue', 'http://fabrikam.com/alleged.html', { test: 1 });
console.log('storageArea before redefine:', evt.storageArea);
evt.constructor.prototype.__defineGetter__('storageArea', function () { return window.sessionStorage; });//don't work
console.log('evt.constructor.prototype.__defineGetter__:', evt.storageArea);
evt.constructor.prototype.__defineGetter__.call(evt, 'storageArea', function () { return window.sessionStorage; });//dont't work
console.log('evt.constructor.prototype.__defineGetter__.call:', evt.storageArea);
evt.__defineGetter__('storageArea', function () { return window.sessionStorage; });//dont't work
console.log('evt.__defineGetter__:', evt.storageArea);
evt.__proto__.__defineGetter__('storageArea', function () { return window.sessionStorage; });//dont't work
console.log('evt.__proto__.__defineGetter__:', evt.storageArea);
window.StorageEvent.__defineGetter__.call(evt, 'storageArea', function () { return window.sessionStorage; });//don't work
console.log('window.StorageEvent.__defineGetter__:', evt.storageArea); |
I found way to override properties of event object: var evt = document.createEvent('StorageEvent');
evt.initStorageEvent('storage',false,false,'key','oldValue','newValue', 'http://fabrikam.com/alleged.html', { test: 1 });
console.log('storageArea before redefine:', evt.storageArea);
evt = { get 'storageArea'() { return window.localStorage; } }; |
@miherlosev how it will help us? :) |
… and Event objects' (close DevExpress#823)
Update: |
In total we cannot override properties of DOM elements and event properties in PhantomJS. |
PhantomJS is died. |
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow. |
We setup events and dom elements in source and test code using
Object.defineProperty
.But PhantomJS doesn't support this - see issue ariya/phantomjs#13895.
Need to investigate way to drop using
Object.defineProperty
.The text was updated successfully, but these errors were encountered: