toolkit/devtools/server/tests/mochitest/test_styles-modify.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug </title>
michael@0 9
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
michael@0 12 <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
michael@0 13 <script type="application/javascript;version=1.8">
michael@0 14 Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
michael@0 15 const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {});
michael@0 16
michael@0 17 const inspector = devtools.require("devtools/server/actors/inspector");
michael@0 18
michael@0 19 window.onload = function() {
michael@0 20 SimpleTest.waitForExplicitFinish();
michael@0 21 runNextTest();
michael@0 22 }
michael@0 23
michael@0 24 var gWalker = null;
michael@0 25 var gStyles = null;
michael@0 26 var gClient = null;
michael@0 27
michael@0 28 addTest(function setup() {
michael@0 29 let url = document.getElementById("inspectorContent").href;
michael@0 30 attachURL(url, function(err, client, tab, doc) {
michael@0 31 gInspectee = doc;
michael@0 32 let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
michael@0 33 let inspector = InspectorFront(client, tab);
michael@0 34 promiseDone(inspector.getWalker().then(walker => {
michael@0 35 ok(walker, "getWalker() should return an actor.");
michael@0 36 gClient = client;
michael@0 37 gWalker = walker;
michael@0 38 return inspector.getPageStyle();
michael@0 39 }).then(styles => {
michael@0 40 gStyles = styles;
michael@0 41 }).then(runNextTest));
michael@0 42 });
michael@0 43 });
michael@0 44
michael@0 45 addTest(function modifyProperties() {
michael@0 46 let localNode = gInspectee.querySelector("#inheritable-rule-inheritable-style");
michael@0 47 let elementStyle = null;
michael@0 48 promiseDone(gWalker.querySelector(gWalker.rootNode, "#inheritable-rule-inheritable-style").then(node => {
michael@0 49 return gStyles.getApplied(node, { inherited: false, filter: "user" });
michael@0 50 }).then(applied => {
michael@0 51 elementStyle = applied[0].rule;
michael@0 52 is(elementStyle.cssText, localNode.style.cssText, "Got expected css text");
michael@0 53
michael@0 54 // Will start with "color:blue"
michael@0 55 let changes = elementStyle.startModifyingProperties();
michael@0 56
michael@0 57 // Change an existing property...
michael@0 58 changes.setProperty("color", "black");
michael@0 59 // Create a new property
michael@0 60 changes.setProperty("background-color", "green");
michael@0 61
michael@0 62 // Create a new property and then change it immediately.
michael@0 63 changes.setProperty("border", "1px solid black");
michael@0 64 changes.setProperty("border", "2px solid black");
michael@0 65
michael@0 66 return changes.apply();
michael@0 67 }).then(() => {
michael@0 68 is(elementStyle.cssText, "color: black; background-color: green; border: 2px solid black;", "Should have expected cssText");
michael@0 69 is(elementStyle.cssText, localNode.style.cssText, "Local node and style front match.");
michael@0 70
michael@0 71 // Remove all the properties
michael@0 72 let changes = elementStyle.startModifyingProperties();
michael@0 73 changes.removeProperty("color");
michael@0 74 changes.removeProperty("background-color");
michael@0 75 changes.removeProperty("border");
michael@0 76
michael@0 77 return changes.apply();
michael@0 78 }).then(() => {
michael@0 79 is(elementStyle.cssText, "", "Should have expected cssText");
michael@0 80 is(elementStyle.cssText, localNode.style.cssText, "Local node and style front match.");
michael@0 81 }).then(runNextTest));
michael@0 82 });
michael@0 83
michael@0 84 addTest(function cleanup() {
michael@0 85 delete gStyles;
michael@0 86 delete gWalker;
michael@0 87 delete gClient;
michael@0 88 runNextTest();
michael@0 89 });
michael@0 90
michael@0 91 </script>
michael@0 92 </head>
michael@0 93 <body>
michael@0 94 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
michael@0 95 <a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
michael@0 96 <p id="display"></p>
michael@0 97 <div id="content" style="display: none">
michael@0 98
michael@0 99 </div>
michael@0 100 <pre id="test">
michael@0 101 </pre>
michael@0 102 </body>
michael@0 103 </html>

mercurial