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

[POC] Nested iFrames Tracker Blocking Test #226

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ <h2>Privacy Protections Tests</h2>
<li><a href='./privacy-protections/amp-loop-protection/'>AMP Loop Protection</a></li>
<li><a href='./privacy-protections/query-parameters/'>Query Parameters</a></li>
<li><a href='./content-scope-scripts/runtime-checks/'>Runtime checks</a></li>
<li><a href="./privacy-protections/request-blocking/nested-frames.html">Nested iFrames</a></li>
</ul>

<h2 id="autofill">Autofill</h2>
Expand Down
58 changes: 58 additions & 0 deletions privacy-protections/request-blocking/nested-frames.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nested Frames Tracker Blocking Test</title>
</head>

<body>
<p><a href="/">[Home]</a></p>

<h1>Nested Frames Tracker Blocking Test</h1>

<p>
Example page that loads trackers in nested frames to check if tracker counts in the new tab page are updated
when child frame requests are blocked.
</p>

<button onclick="loadTracker('parent')">Load Tracker in Parent Frame</button>
<button onclick="loadTracker('child')">Load Tracker in Child Frame</button>

<script src="http://bad.third-party.site/privacy-protections/request-blocking/block-me/script.js"></script>
<script>
const [parentFrame, childFrame] = createFrames();

function createFrames() {
const parent = document.createElement('iframe');
const child = document.createElement('iframe');
parent.name = "parent-frame";
parent.id = "parent-frame";
child.name = "child-frame";
child.id = "child-frame";

document.body.appendChild(parent);
parent.contentDocument.body.appendChild(child);

return [parent, child];
}

function loadTracker(frameType) {
const trackerSrc = frameType === 'parent'
? "http://broken.third-party.site/privacy-protections/request-blocking/block-me/script.js"
: "http://privacy-test-pages.site/privacy-protections/request-blocking/block-me/script.js";

const scriptElm = document.createElement('script');
scriptElm.src = trackerSrc;

if (frameType === 'parent') {
parentFrame.contentDocument.body.appendChild(scriptElm);
} else {
childFrame.contentDocument.body.appendChild(scriptElm);
}
}
</script>
</body>

</html>
Loading