1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/window_chromemargin.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +<?xml version="1.0"?> 1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.6 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.8 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.9 + 1.10 +<window id="window" title="Subframe Origin Tests" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 +<script type="application/javascript" 1.13 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 1.14 +chrome margins rock! 1.15 +<script> 1.16 + 1.17 +// Tests parsing of the chrome margin attrib on a window. 1.18 + 1.19 +function ok(condition, message) { 1.20 + window.opener.wrappedJSObject.SimpleTest.ok(condition, message); 1.21 +} 1.22 + 1.23 +function doSingleTest(param, shouldSucceed) 1.24 +{ 1.25 + var exception = null; 1.26 + try { 1.27 + document.documentElement.removeAttribute("chromemargin"); 1.28 + document.documentElement.setAttribute("chromemargin", param); 1.29 + ok(document. 1.30 + documentElement. 1.31 + getAttribute("chromemargin") == param, "couldn't set/get chromemargin?"); 1.32 + } catch (ex) { 1.33 + exception = ex; 1.34 + } 1.35 + if (shouldSucceed) 1.36 + ok(!exception, "failed for param:'" + param + "'"); 1.37 + else 1.38 + ok(exception, "did not fail for invalid param:'" + param + "'"); 1.39 + return true; 1.40 +} 1.41 + 1.42 +function runTests() 1.43 +{ 1.44 + var doc = document.documentElement; 1.45 + 1.46 + // make sure we can set and get 1.47 + doc.setAttribute("chromemargin", "0,0,0,0"); 1.48 + ok(doc.getAttribute("chromemargin") == "0,0,0,0", "couldn't set/get chromemargin?"); 1.49 + doc.setAttribute("chromemargin", "-1,-1,-1,-1"); 1.50 + ok(doc.getAttribute("chromemargin") == "-1,-1,-1,-1", "couldn't set/get chromemargin?"); 1.51 + 1.52 + // test remove 1.53 + doc.removeAttribute("chromemargin"); 1.54 + ok(doc.getAttribute("chromemargin") == "", "couldn't remove chromemargin?"); 1.55 + 1.56 + // we already test these really well in a c++ test in widget 1.57 + doSingleTest("1,2,3,4", true); 1.58 + doSingleTest("-2,-2,-2,-2", true); 1.59 + doSingleTest("1,1,1,1", true); 1.60 + doSingleTest("", false); 1.61 + doSingleTest("12123123", false); 1.62 + doSingleTest("0,-1,-1,-1", true); 1.63 + doSingleTest("-1,0,-1,-1", true); 1.64 + doSingleTest("-1,-1,0,-1", true); 1.65 + doSingleTest("-1,-1,-1,0", true); 1.66 + doSingleTest("1234567890,1234567890,1234567890,1234567890", true); 1.67 + doSingleTest("-1,-1,-1,-1", true); 1.68 + 1.69 + window.opener.wrappedJSObject.SimpleTest.finish(); 1.70 + window.close(); 1.71 +} 1.72 + 1.73 +window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window); 1.74 + 1.75 +</script> 1.76 +</window>