-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Topics module: Initial Topics iframe implementation (#8947)
* Topics: Initial Topics iframe implementation * Topics API: LINT errors solved * Added Empty Topics Check * Topics: Storage Map logic and added message listener secure check * Topics: Iframe implementation for bidders * Added topics_iframe html in example for reference * Added Pubmatic Topic iframe URL * Added Pubmatic Topic iframe URL- Removed comment * Topics Module: Consent management logic added * Topics Module: Added Device Access check * Topics Module: Unit test cases added and minor changes * Topics Module: Array.find used instead of array.some and variable name changed * Topics IFrame Implementation: Purpose present check is handled
- Loading branch information
1 parent
bc68d77
commit 77ba4ec
Showing
3 changed files
with
401 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Topics demo</title> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="favicon.ico" rel="shortcut icon"> | ||
<script> | ||
async function getTopics() { | ||
try { | ||
if ('browsingTopics' in document && document.featurePolicy.allowsFeature('browsing-topics')) { | ||
const topics = await document.browsingTopics(); | ||
console.log('Called iframe:', window.location.hostname, topics, '\nNumber of topics: ', topics.length); | ||
return Promise.resolve(topics); | ||
} else { | ||
console.log('document.browsingTopics() not supported'); | ||
} | ||
|
||
} catch (error) { | ||
console.log('Error:', error); | ||
} | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', async function () { | ||
const topics = await getTopics() | ||
const url = new URL(window.location.href); | ||
const params = new URLSearchParams(url.search); | ||
const message = JSON.stringify({ | ||
segment: { | ||
domain: window.location.hostname, | ||
topics, | ||
bidder: params.get("bidder") | ||
}, | ||
date: Date.now(), | ||
}); | ||
window.parent.postMessage(message, '*'); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.