これが例です
parent.html
<script>
function printWhoCalledMe() {
console.log(???); // what goes here that will identify the caller?
}
<iframe src="iframe1.html"></iframe>
<iframe src="iframe2.html"></iframe>
iframe1.html
<script>
window.parent.printWhoCalledMe();
</script>
iframe2.html
<script>
window.parent.printWhoCalledMe();
</script>
より大きな質問は、iframeで一度に1つずつ一連のテストを実行するテストハーネスがあることです。各テスト呼び出しwindow.parent.reportOnTest(success)
1つ以上のiframeでテストを実行して並列化することを検討していますが、すべてのテスト、現在は1000のテストを実行し、呼び出しをからそのwindow.parent.reportOnTest(success)
ようなものに変更する必要がありwindow.parent.reportOnTest(success, window.location.href)
ます。
テストを変更せずに、どのテストが親を呼び出しているかを把握する方法があるかどうか疑問に思っています。
注:試してみました
function printWhoCalledMe() {
console.log(window.location.href);
}
しかし、それは親のhrefを出力します。