content/xul/document/test/test_bug640158_overlay_persist.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xul/document/test/test_bug640158_overlay_persist.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=640158
     1.9 +-->
    1.10 +<window title="Mozilla Bug 640158" id="rootwin"
    1.11 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.13 +
    1.14 +  <!-- test results are displayed in the html:body -->
    1.15 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.16 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=640158"
    1.17 +     target="_blank">Mozilla Bug 640158</a>
    1.18 +  </body>
    1.19 +
    1.20 +  <!-- test code goes here -->
    1.21 +  <script type="application/javascript"><![CDATA[
    1.22 +
    1.23 +  SimpleTest.waitForExplicitFinish();
    1.24 +  window.onload = function onload() {
    1.25 +    is($("foo").getAttribute("testattr"), "original", "Attribute should be in original state");
    1.26 +    // Change and persist another value:
    1.27 +    $("foo").setAttribute("testattr", "changed");
    1.28 +    document.persist("foo", "testattr");
    1.29 +    $("foo").setAttribute("testattr", "original");
    1.30 +
    1.31 +    // Hacky times: check that items which are overlaid do get persisted into correctly,
    1.32 +    // by first creating an extra element and persisting the value before loading an
    1.33 +    // overlay that changes that value - the persisted value should be reinstated.
    1.34 +    let root = document.documentElement;
    1.35 +    let bar = document.createElement("box");
    1.36 +    bar.id = "bar";
    1.37 +    bar.setAttribute("testattr", "changed"); // The overlay we load has 'original'
    1.38 +    root.appendChild(bar);
    1.39 +    document.persist("bar", "testattr");
    1.40 +    document.loadOverlay(location.href.replace(/[^\\\/]*.xul/, "overlay_bug640158.xul"), function() {
    1.41 +      is($("foo").getAttribute("testattr"), "original",
    1.42 +         "Non-overlaid attribute should still be in original state");
    1.43 +      is($("bar").getAttribute("testattr"), "changed",
    1.44 +         "Overlaid attribute should have been changed.");
    1.45 +      SimpleTest.finish();
    1.46 +    });
    1.47 +  }
    1.48 +
    1.49 +  ]]></script>
    1.50 +
    1.51 +  <box id="foo" testattr="original"/>
    1.52 +
    1.53 +</window>
    1.54 +

mercurial