I learned a trick to detect if a frame is cross-origin.
window.top.location.href throws a SecurityError when
when being evaluated from a cross-origin iframe.
This is similar in practice to window.frameElement,
except that it handles the case of nested iframes with an intermediate same-origin iframe.
For example:
You can test this by switching contexts in the browser inspector console, and evaluating some of the expressions below.
Switching Contexts
In Chrome, you can visit the Console tab, and change the context via the dropdown immediately beflow the tab.
In Safari and Firefox, the context selector should be right beside the console input.
Below are some iframes to this site itself.