blob: d916cc91ec7b4f57a44915dbf1f8562d474500ec [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script src="../debugger/resources/breakpoint-options-utilities.js"></script>
<script src="../debugger/resources/log-active-stack-trace.js"></script>
<script src="../worker/resources/resource-utilities.js"></script>
<script src="resources/url-breakpoint-utilities.js"></script>
<script>
function test()
{
const type = WI.URLBreakpoint.Type.RegularExpression;
const url = "data[A-Z]*\.(json|txt|png)";
let suite = InspectorTest.createAsyncSuite("URLBreakpoint.BreakOnMatchingRegularExpression");
for (let api of ["Fetch", "XHR"]) {
suite.addTestCase({
name: "URLBreakpoint.BreakOnMatchingRegularExpression." + api,
description: "Check that debugger pauses based on a URL matching a regex pattern.",
async test() {
let breakpoint = await InspectorTest.URLBreakpoint.createBreakpoint(type, url);
InspectorTest.URLBreakpoint.request(api);
await WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
InspectorTest.log("PAUSED:");
InspectorTest.expectEqual(targetData.pauseReason, WI.DebuggerManager.PauseReason[api], `Pause reason should be ${api}.`);
InspectorTest.expectEqual(targetData.pauseData.breakpointURL, breakpoint.url, "Pause data URL should match breakpoint URL.");
logActiveStackTrace();
await WI.debuggerManager.resume();
},
teardown: InspectorTest.URLBreakpoint.teardown,
});
InspectorTest.BreakpointOptions.addTestCases(suite, {
testCaseNamePrefix: api + ".",
createBreakpoint() {
return InspectorTest.URLBreakpoint.createBreakpoint(type, url);
},
triggerBreakpoint() {
return InspectorTest.URLBreakpoint.request(api);
},
});
}
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for regex URL breakpoints.</p>
</body>
</html>