Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  test_bug557726.html   Sprache: HTML

 
 products/sources/formale Sprachen/C/Firefox/layout/inspector/tests/test_bug557726.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=557726
-->

<head>
  <title>Test for Bug 557726</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <style id="pseudo-style">
    #div1 {
      color: blue;
    }

    #div1:first-letter {
      font-weight: bold;
    }

    #div1:before {
      content: '"';
    }

    #div1:after {
      content: '"';
    }

    #div1:after, #div1:before {
      color: red;
    }

    ::selection {
      background: pink;
    }

    ::highlight(search) {
      background: yellow;
    }

    ::highlight(whatever) {
      background: tomato;
    }
  </style>
</head>
<body>

<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=557726">Mozilla Bug 557726</a>

<div id="div1">
  text with ::before, ::after, and ::first-letter pseudo-elements
</div>

<script type="application/javascript">

/** Test for Bug 557726 **/
const InspectorUtils = SpecialPowers.InspectorUtils;

function getSelectors (rules) {
  var styleElement = document.getElementById("pseudo-style");
  var selectors = [];
  for (var i = 0; i < rules.length; i++) {
    var rule = rules[i];
    if (SpecialPowers.unwrap(rule.parentStyleSheet.ownerNode) == styleElement) // no user agent rules
      selectors.push(rule.selectorText);
  }
  return selectors;
}

var div = document.getElementById("div1");

/* empty or missing pseudo-element argument */
var selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div));
is(selectors.length, 1, "psuedo-element argument should be optional");
is(selectors[0], "#div1""should only have the non-pseudo element rule");

selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div""));
is(selectors.length, 1, "pseudo-element argument can be empty string");
is(selectors[0], "#div1""should only have the non pseudo-element rule");


/* invalid pseudo-element argument */
var rules = InspectorUtils.getMatchingCSSRules(div"not a valid pseudo element");
is(rules.length, 0, "invalid pseudo-element returns no rules");


/* valid pseudo-element argument */
selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div":first-letter"));
is(selectors.length, 1, "pseudo-element argument can be used");
is(selectors[0], "#div1::first-letter""should only have the ::first-letter rule");

selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div":before"));
is(selectors.length, 2, "::before pseudo-element has two matching rules");
isnot(selectors.indexOf("#div1::after, #div1::before"), -1, "fetched rule for ::before")
isnot(selectors.indexOf("#div1::before"), -1, "fetched rule for ::before")

selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div":first-line"));
is(selectors.length, 0, "valid pseudo-element but no matching rules");

selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div"::selection"));
is(selectors.length, 1, "::selection pseudo-element has a matching rule");
is(selectors[0], "::selection""fetched rule for ::selection");

const range = new Range();
range.setStart(div.firstChild, 10);
range.setEnd(div.firstChild, 20);
const highlight = new Highlight(range);
CSS.highlights.set("search", highlight);

selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div"::highlight(search)"));
is(selectors.length, 1, "::highlight(search) pseudo-element has a matching rule");
is(selectors[0], "::highlight(search)""fetched ::highlight(search) rule");

selectors = getSelectors(InspectorUtils.getMatchingCSSRules(div"::highlight(whatever)"));
is(selectors.length, 1, "::highlight(whatever) pseudo-element has a matching rule");
is(selectors[0], "::highlight(whatever)""fetched ::highlight(whatever) rule");

</script>
</pre>
</body>
</html>

Messung V0.5
C=97 H=96 G=96

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge