75 lines
2.7 KiB
HTML
75 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
|
|
<style>
|
|
body { color: blue; }
|
|
@media print {
|
|
body { color: green; }
|
|
}
|
|
</style>
|
|
<script>
|
|
let mediaQueryList = window.matchMedia("print");
|
|
mediaQueryList.addListener(function(aMediaQueryList) {
|
|
TestPage.addResult("PASS: MediaQueryList listener fired.");
|
|
});
|
|
|
|
function test()
|
|
{
|
|
let suite = InspectorTest.createAsyncSuite("Page.setEmulatedMedia");
|
|
|
|
suite.addTestCase({
|
|
name: "Page.setEmulatedMedia.initial",
|
|
description: "Initial media type should match screen.",
|
|
test(resolve, reject) {
|
|
InspectorTest.evaluateInPage("mediaQueryList.matches", (error, result) => {
|
|
InspectorTest.expectEqual(result, false, "Page should not match print media.");
|
|
});
|
|
InspectorTest.evaluateInPage("getComputedStyle(document.body).color", (error, result) => {
|
|
InspectorTest.expectEqual(result, "rgb(0, 0, 255)", "Body color should be blue.");
|
|
resolve();
|
|
});
|
|
}
|
|
});
|
|
|
|
suite.addTestCase({
|
|
name: "Page.setEmulatedMedia.print",
|
|
description: "Should be able to set print media type.",
|
|
test(resolve, reject) {
|
|
PageAgent.setEmulatedMedia("print", (error) => {
|
|
InspectorTest.evaluateInPage("mediaQueryList.matches", (error, result) => {
|
|
InspectorTest.expectEqual(result, true, "Page should now match print media.");
|
|
});
|
|
InspectorTest.evaluateInPage("getComputedStyle(document.body).color", (error, result) => {
|
|
InspectorTest.expectEqual(result, "rgb(0, 128, 0)", "Body color should be green.");
|
|
resolve();
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
suite.addTestCase({
|
|
name: "Page.setEmulatedMedia.reset",
|
|
description: "Should be able to reset media type to screen.",
|
|
test(resolve, reject) {
|
|
PageAgent.setEmulatedMedia("", (error) => {
|
|
InspectorTest.evaluateInPage("mediaQueryList.matches", (error, result) => {
|
|
InspectorTest.expectEqual(result, false, "Page should now not match print media.");
|
|
});
|
|
InspectorTest.evaluateInPage("getComputedStyle(document.body).color", (error, result) => {
|
|
InspectorTest.expectEqual(result, "rgb(0, 0, 255)", "Page should now match print media.");
|
|
resolve();
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
suite.runTestCasesAndFinish();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="runTest()">
|
|
<p>Tests for the Page.setEmulatedMedia command.</p>
|
|
</body>
|
|
</html>
|