summaryrefslogtreecommitdiffstats
path: root/platform/browser/test.html
diff options
context:
space:
mode:
Diffstat (limited to 'platform/browser/test.html')
-rw-r--r--platform/browser/test.html71
1 files changed, 71 insertions, 0 deletions
diff --git a/platform/browser/test.html b/platform/browser/test.html
new file mode 100644
index 0000000..32b1aba
--- /dev/null
+++ b/platform/browser/test.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>uBO Static Network Filtering Engine</title>
+</head>
+<body>
+<script type="module">
+ import {
+ FilteringContext,
+ enableWASM,
+ pslInit,
+ restart,
+ } from './main.js';
+
+ (async ( ) => {
+ await enableWASM('.');
+
+ await fetch('./data/effective_tld_names.dat').then(response => {
+ return response.text();
+ }).then(pslRaw => {
+ pslInit(pslRaw);
+ });
+
+ const snfe = await Promise.all([
+ fetch('./data/easylist.txt').then(response => {
+ return response.text();
+ }),
+ fetch('./data/easyprivacy.txt').then(response => {
+ return response.text();
+ }),
+ ]).then(rawLists => {
+ return restart([
+ { name: 'easylist', raw: rawLists[0] },
+ { name: 'easyprivacy', raw: rawLists[1] },
+ ]);
+ });
+
+ // Reuse filtering context: it's what uBO does
+ const fctxt = new FilteringContext();
+
+ // Tests
+ // Not blocked
+ fctxt.setDocOriginFromURL('https://www.bloomberg.com/');
+ fctxt.setURL('https://www.bloomberg.com/tophat/assets/v2.6.1/that.css');
+ fctxt.setType('stylesheet');
+ if ( snfe.matchRequest(fctxt) !== 0 ) {
+ console.log(snfe.toLogData());
+ }
+
+ // Blocked
+ fctxt.setDocOriginFromURL('https://www.bloomberg.com/');
+ fctxt.setURL('https://securepubads.g.doubleclick.net/tag/js/gpt.js');
+ fctxt.setType('script');
+ if ( snfe.matchRequest(fctxt) !== 0 ) {
+ console.log(snfe.toLogData());
+ }
+
+ // Unblocked
+ fctxt.setDocOriginFromURL('https://www.bloomberg.com/');
+ fctxt.setURL('https://sourcepointcmp.bloomberg.com/ccpa.js');
+ fctxt.setType('script');
+ if ( snfe.matchRequest(fctxt) !== 0 ) {
+ console.log(snfe.toLogData());
+ }
+
+ restart();
+ })();
+</script>
+</body>
+</html>