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

Add test cases to check blocking uuid-in-package subresource loading #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ var filters = [
{urls: ['*://*/*fetch_result_2_unsigned_bundle*'], types: ['xmlhttprequest']},
{urls: ['*://*/*xhr_result_2_unsigned_bundle*'], types: ['xmlhttprequest']},
{urls: ['*://*/*blocked_bundle.wbn']}, // should be {urls: ['*://*/*blocked_bundle*'], types: ['webbundle']} (ref. https://crbug.com/41031645)
{urls: ['uuid-in-package:298bedfd-91ba-4030-bc35-8040c6536d5d'], types: ['sub_frame']},
{urls: ['uuid-in-package:a94ddaa3-6042-44db-9b8f-cb77b6b72999'], types: ['script']},
{urls: ['uuid-in-package:9cac3c3a-0a40-49aa-b05a-e06ff64f81ff'], types: ['image']},
];

filters.forEach(filter => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*/"
"<all_urls>"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,44 @@
"webbundle"
]
}
},
{
"id": 21,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"urlFilter": "uuid-in-package:298bedfd-91ba-4030-bc35-8040c6536d5d",
"resourceTypes": [
"sub_frame"
]
}
},
{
"id": 22,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"urlFilter": "uuid-in-package:a94ddaa3-6042-44db-9b8f-cb77b6b72999",
"resourceTypes": [
"script"
]
}
},
{
"id": 23,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"urlFilter": "uuid-in-package:9cac3c3a-0a40-49aa-b05a-e06ff64f81ff",
"resourceTypes": [
"image"
]
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
{"source": "by_resource/red_subresource_loading.css"},
{"source": "by_resource/red_subresource_loading.png"},
{"source": "by_resource/fetch_result_1_subresource_loading.json"},
{"source": "by_resource/xhr_result_1_subresource_loading.json"}
{"source": "by_resource/xhr_result_1_subresource_loading.json"},
{"source": "by_resource/subframe_subresource_loading.html",
"uuid": "298bedfd-91ba-4030-bc35-8040c6536d5d"},
{"source": "by_resource/script_subresource_loading.js",
"uuid": "a94ddaa3-6042-44db-9b8f-cb77b6b72999"},
{"source": "by_resource/skyblue_subresource_loading.png",
"uuid": "9cac3c3a-0a40-49aa-b05a-e06ff64f81ff"}
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('script_2.js loaded');
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<p>This is a subframe</p>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"by_resource/red_subresource_loading.css",
"by_resource/red_subresource_loading.png",
"by_resource/fetch_result_1_subresource_loading.json",
"by_resource/xhr_result_1_subresource_loading.json"
"by_resource/xhr_result_1_subresource_loading.json",
"uuid-in-package:298bedfd-91ba-4030-bc35-8040c6536d5d",
"uuid-in-package:a94ddaa3-6042-44db-9b8f-cb77b6b72999",
"uuid-in-package:9cac3c3a-0a40-49aa-b05a-e06ff64f81ff"
]
}
</script>
Expand Down Expand Up @@ -88,6 +91,12 @@ img {
<br><code id='xhr_result_by_resource'>Pending</code></li>
<li>Shows fetch result for by_resource/fetch_result_1_subresource_loading.json:
<br><code id='fetch_result_by_resource'>Pending</code></li>
<li>Shows by_resource/subframe_subresource_loading.html, nothing after the html blocked (uuid-in-package:298bedfd-91ba-4030-bc35-8040c6536d5d):
<br><iframe src="uuid-in-package:298bedfd-91ba-4030-bc35-8040c6536d5d" width="100%" height="50px"></iframe></li>
<li>Shows by_resource/script_subresource_loading.js loading result (uuid-in-package:a94ddaa3-6042-44db-9b8f-cb77b6b72999):
<br><code id='script_result_by_resource'>Pending</code></li>
<li>Shows by_resource/skyblue_subresource_loading.png, nothing after the png blocked (uuid-in-package:9cac3c3a-0a40-49aa-b05a-e06ff64f81ff):
<br><img src="uuid-in-package:9cac3c3a-0a40-49aa-b05a-e06ff64f81ff" /></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -171,11 +180,24 @@ function testFetchXHR(method, url, log_element) {
log_element.innerHTML = `Invalid method: ${method}`;
}
}
function testScriptLoad(url, log_element) {
const script = document.createElement('script');
script.addEventListener('load', () => {
log_element.innerHTML = `${url} loaded`;
});
script.addEventListener('error', () => {
log_element.innerHTML = `${url} loading error`;
});
script.src = url;
document.body.appendChild(script);
}

testFetchXHR("xhr", "by_resource/xhr_result_1_subresource_loading.json", xhr_result_by_resource);
testFetchXHR("fetch", "by_resource/fetch_result_1_subresource_loading.json", fetch_result_by_resource);
testFetchXHR("xhr", "by_bundle_file/xhr_result_2_subresource_loading.json", xhr_result_by_bundle_file);
testFetchXHR("fetch", "by_bundle_file/fetch_result_2_subresource_loading.json", fetch_result_by_bundle_file);
testFetchXHR("xhr", "by_scope/xhr_result_3_subresource_loading.json", xhr_result_by_scope);
testFetchXHR("fetch", "by_scope/fetch_result_3_subresource_loading.json", fetch_result_by_scope);

testScriptLoad('uuid-in-package:a94ddaa3-6042-44db-9b8f-cb77b6b72999', script_result_by_resource);
</script>