blob: bc465df550ee42fd2c2f6d16cdd46c922ecbd09a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<!DOCTYPE HTML>
<html>
<!--
Test that css-logic handles media-queries correctly
-->
<head>
<meta charset="utf-8">
<title>Test css-logic media-queries</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<style>
div {
width: 1000px;
height: 100px;
background-color: #f00;
}
@media screen and (min-width: 1px) {
div {
width: 200px;
}
}
</style>
</head>
<body>
<div></div>
<script type="application/javascript;version=1.8">
window.onload = function() {
var { classes: Cc, utils: Cu, interfaces: Ci } = Components;
const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils);
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var Services = require("Services");
const {CssLogic} = require("devtools/server/css-logic");
SimpleTest.waitForExplicitFinish();
let div = document.querySelector("div");
let cssLogic = new CssLogic(DOMUtils.isInheritedProperty);
cssLogic.highlight(div);
cssLogic.processMatchedSelectors();
let _strings = Services.strings
.createBundle("chrome://devtools-shared/locale/styleinspector.properties");
let inline = _strings.GetStringFromName("rule.sourceInline");
let source1 = inline + ":12";
let source2 = inline + ":19 @media screen and (min-width: 1px)";
is(cssLogic._matchedRules[0][0].source, source1,
"rule.source gives correct output for rule 1");
is(cssLogic._matchedRules[1][0].source, source2,
"rule.source gives correct output for rule 2");
SimpleTest.finish();
}
</script>
</body>
</html>
|