Skip to content
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

Fix tests for error type of __proto__ on cross-domain objects #5163

Merged
merged 2 commits into from Mar 16, 2017

Conversation

domenic
Copy link
Member

@domenic domenic commented Mar 16, 2017

This is a follow-up to #5015 which corrects a problem noted by Boris in https://bugzilla.mozilla.org/show_bug.cgi?id=1347706#c2.

@domenic domenic requested a review from bzbarsky March 16, 2017 21:17
@wpt-pr-bot
Copy link
Collaborator

Copy link
Contributor

@bzbarsky bzbarsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the nit.

test(() => {
assert_throws(new TypeError, () => {
Object.setPrototypeOf(target, newValue);
});
}, `${prefix}: setting the prototype to ${newValueString} via Object.setPrototypeOf should throw a TypeError`);

const dunderProtoError = isSameOriginDomain ? { name: "TypeError" } : { name: "SecurityError" };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't check for the "SecurityError" being a DOMException. How about:

const dunderProtoError = isSameOriginDomain ? new TypeError() : "SecurityError";

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I didn't realize. Fixed, PTAL.

target.__proto__ = newValue;
});
}, `${prefix}: setting the prototype to ${newValueString} via __proto__ should throw a TypeError`);
}, `${prefix}: setting the prototype to ${newValueString} via __proto__ should throw a ${dunderProtoError.name}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that makes this last bit harder, but we could just stash the string we care about in another variable to use here.

@w3c-bots
Copy link

w3c-bots commented Mar 16, 2017

View the complete job log.

Firefox (nightly channel)

Testing web-platform-tests at revision 1213ada
Using browser at version BuildID 20170314110401; SourceStamp 6d38ad302429c98115c354d643e81987ecec5d3c
Starting 10 test iterations
All results were stable

All results

10 tests ran
/html/browsers/history/the-location-interface/location-prototype-setting-cross-origin-domain.sub.html
Subtest Results Messages
OK
Cross-origin via document.domain: the prototype is null PASS
Cross-origin via document.domain: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Cross-origin via document.domain: setting the prototype to an empty object via __proto__ should throw a "SecurityError" DOMException PASS
Cross-origin via document.domain: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Cross-origin via document.domain: the prototype must still be null PASS
Cross-origin via document.domain: setting the prototype to null via Object.setPrototypeOf should not throw FAIL can't set prototype of this object
Cross-origin via document.domain: setting the prototype to null via __proto__ should throw a "SecurityError" since it ends up in CrossOriginGetOwnProperty PASS
Cross-origin via document.domain: setting the prototype to null via Reflect.setPrototypeOf should return true FAIL assert_true: expected true got false
/html/browsers/history/the-location-interface/location-prototype-setting-cross-origin.sub.html
Subtest Results Messages
OK
Cross-origin: the prototype is null PASS
Cross-origin: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Cross-origin: setting the prototype to an empty object via __proto__ should throw a "SecurityError" DOMException PASS
Cross-origin: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Cross-origin: the prototype must still be null PASS
Cross-origin: setting the prototype to null via Object.setPrototypeOf should not throw FAIL can't set prototype of this object
Cross-origin: setting the prototype to null via __proto__ should throw a "SecurityError" since it ends up in CrossOriginGetOwnProperty PASS
Cross-origin: setting the prototype to null via Reflect.setPrototypeOf should return true FAIL assert_true: expected true got false
/html/browsers/history/the-location-interface/location-prototype-setting-goes-cross-origin-domain.sub.html
Subtest Results Messages
OK
Same-origin (for now): the prototype is accessible PASS
Became cross-origin via document.domain: the prototype is now null PASS
Became cross-origin via document.domain: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Became cross-origin via document.domain: setting the prototype to an empty object via __proto__ should throw a "SecurityError" DOMException PASS
Became cross-origin via document.domain: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Became cross-origin via document.domain: the prototype must still be null PASS
Became cross-origin via document.domain: setting the prototype to null via Object.setPrototypeOf should not throw FAIL can't set prototype of this object
Became cross-origin via document.domain: setting the prototype to null via __proto__ should throw a "SecurityError" since it ends up in CrossOriginGetOwnProperty PASS
Became cross-origin via document.domain: setting the prototype to null via Reflect.setPrototypeOf should return true FAIL assert_true: expected true got false
Became cross-origin via document.domain: setting the prototype to the original value from before going cross-origin via Object.setPrototypeOf should throw a TypeError PASS
Became cross-origin via document.domain: setting the prototype to the original value from before going cross-origin via __proto__ should throw a "SecurityError" DOMException PASS
Became cross-origin via document.domain: setting the prototype to the original value from before going cross-origin via Reflect.setPrototypeOf should return false PASS
/html/browsers/history/the-location-interface/location-prototype-setting-same-origin-domain.sub.html
Subtest Results Messages
OK
Same-origin-domain prerequisite check: the original prototype is accessible PASS
Same-origin-domain: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Same-origin-domain: setting the prototype to an empty object via __proto__ should throw a TypeError PASS
Same-origin-domain: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Same-origin-domain: the prototype must still be its original value PASS
Same-origin-domain: setting the prototype to its original value via Object.setPrototypeOf should not throw PASS
Same-origin-domain: setting the prototype to its original value via __proto__ should not throw PASS
Same-origin-domain: setting the prototype to its original value via Reflect.setPrototypeOf should return true PASS
/html/browsers/history/the-location-interface/location-prototype-setting-same-origin.html
Subtest Results Messages
OK
Same-origin prerequisite check: the original prototype is accessible PASS
Same-origin: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Same-origin: setting the prototype to an empty object via __proto__ should throw a TypeError PASS
Same-origin: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Same-origin: the prototype must still be its original value PASS
Same-origin: setting the prototype to its original value via Object.setPrototypeOf should not throw PASS
Same-origin: setting the prototype to its original value via __proto__ should not throw PASS
Same-origin: setting the prototype to its original value via Reflect.setPrototypeOf should return true PASS
/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin-domain.sub.html
Subtest Results Messages
OK
Cross-origin via document.domain: the prototype is null PASS
Cross-origin via document.domain: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Cross-origin via document.domain: setting the prototype to an empty object via __proto__ should throw a "SecurityError" DOMException PASS
Cross-origin via document.domain: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Cross-origin via document.domain: the prototype must still be null PASS
Cross-origin via document.domain: setting the prototype to null via Object.setPrototypeOf should not throw FAIL can't set prototype of this object
Cross-origin via document.domain: setting the prototype to null via __proto__ should throw a "SecurityError" since it ends up in CrossOriginGetOwnProperty PASS
Cross-origin via document.domain: setting the prototype to null via Reflect.setPrototypeOf should return true FAIL assert_true: expected true got false
/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin.sub.html
Subtest Results Messages
OK
Cross-origin: the prototype is null PASS
Cross-origin: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Cross-origin: setting the prototype to an empty object via __proto__ should throw a "SecurityError" DOMException PASS
Cross-origin: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Cross-origin: the prototype must still be null PASS
Cross-origin: setting the prototype to null via Object.setPrototypeOf should not throw FAIL can't set prototype of this object
Cross-origin: setting the prototype to null via __proto__ should throw a "SecurityError" since it ends up in CrossOriginGetOwnProperty PASS
Cross-origin: setting the prototype to null via Reflect.setPrototypeOf should return true FAIL assert_true: expected true got false
/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html
Subtest Results Messages
OK
Same-origin (for now): the prototype is accessible PASS
Became cross-origin via document.domain: the prototype is now null PASS
Became cross-origin via document.domain: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Became cross-origin via document.domain: setting the prototype to an empty object via __proto__ should throw a "SecurityError" DOMException PASS
Became cross-origin via document.domain: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Became cross-origin via document.domain: the prototype must still be null PASS
Became cross-origin via document.domain: setting the prototype to null via Object.setPrototypeOf should not throw FAIL can't set prototype of this object
Became cross-origin via document.domain: setting the prototype to null via __proto__ should throw a "SecurityError" since it ends up in CrossOriginGetOwnProperty PASS
Became cross-origin via document.domain: setting the prototype to null via Reflect.setPrototypeOf should return true FAIL assert_true: expected true got false
Became cross-origin via document.domain: setting the prototype to the original value from before going cross-origin via Object.setPrototypeOf should throw a TypeError PASS
Became cross-origin via document.domain: setting the prototype to the original value from before going cross-origin via __proto__ should throw a "SecurityError" DOMException PASS
Became cross-origin via document.domain: setting the prototype to the original value from before going cross-origin via Reflect.setPrototypeOf should return false PASS
/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-domain.sub.html
Subtest Results Messages
OK
Same-origin-domain prerequisite check: the original prototype is accessible PASS
Same-origin-domain: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Same-origin-domain: setting the prototype to an empty object via __proto__ should throw a TypeError PASS
Same-origin-domain: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Same-origin-domain: the prototype must still be its original value PASS
Same-origin-domain: setting the prototype to its original value via Object.setPrototypeOf should not throw PASS
Same-origin-domain: setting the prototype to its original value via __proto__ should not throw PASS
Same-origin-domain: setting the prototype to its original value via Reflect.setPrototypeOf should return true PASS
/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin.html
Subtest Results Messages
OK
Same-origin prerequisite check: the original prototype is accessible PASS
Same-origin: setting the prototype to an empty object via Object.setPrototypeOf should throw a TypeError PASS
Same-origin: setting the prototype to an empty object via __proto__ should throw a TypeError PASS
Same-origin: setting the prototype to an empty object via Reflect.setPrototypeOf should return false PASS
Same-origin: the prototype must still be its original value PASS
Same-origin: setting the prototype to its original value via Object.setPrototypeOf should not throw PASS
Same-origin: setting the prototype to its original value via __proto__ should not throw PASS
Same-origin: setting the prototype to its original value via Reflect.setPrototypeOf should return true PASS

@w3c-bots
Copy link

w3c-bots commented Mar 16, 2017

View the complete job log.

Chrome (unstable channel)

Testing web-platform-tests at revision 1213ada
Using browser at version 58.0.3029.19 dev
Starting 10 test iterations

@w3c-bots
Copy link

w3c-bots commented Mar 16, 2017

These tests are now available on w3c-test.org

Copy link
Contributor

@bzbarsky bzbarsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@domenic domenic merged commit b54f0a6 into master Mar 16, 2017
@domenic domenic deleted the fixup-crossoriginprotos branch March 16, 2017 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants