18 tests to run in 7 groups
------------------------------------------------------------
GROUP "basicChecks" has 1 test to run
basicChecks: setContent
/basicChecks: setContent
PASSED test: setContent 1 ms
Total time for GROUP " basicChecks " is 1ms
Total time for GROUP " basicChecks " is 1ms
------------------------------------------------------------
GROUP "pathAdjustments" has 3 tests to run
pathAdjustments: cssPathAdjustments
in cssPathAdjustments, returning function
in cssPathAdjustments, calling set
Error: Cannot read properties of undefined (reading 'then')
ERROR IN:
function(t){
// test that when you setContent, using the adjustPaths and renderStyles options
// the paths in the css are corrected for the current document
console.log("pathAdjustments: " + this.name);
// we do this test as one big string to emulate as good as possible,
// but split it later to easily see where we failed
var cssText = ".easy{ background-image:url(images/image.png) }\n"
+".dontReplaceEasy{ background-image:url(images/images/image.png) }\n"
+".hardurl{background-image:url(\t \"../../source/~test/%20t'e(s)t.gif(\"1')?foo=bar11103&bar=baz-foo\" \t);}body{};\n"
+".file{background-image: url(file:///home/nobody/image.png);}\n"
+".http{background-image: url(http://dojotoolkit.org/image.png);}\n"
+".https{background-image: url(https://dojotoolkit.org/image.png);}\n"
+".nonRelative{background-image:url(/toplevelfolder/image.gif);}\n"
+'@import "css/main.css";' + "\n@import \t'css/Newbee Url.css'\t;\n"
+"@import 'http://dojotoolkit.org/dojo.css';\n"
+" @import 'you/never/thought/' print;\n"
+' @import url("it/would/work") tv, screen;'+"\n"
+' @import url(/did/you/now.css);'+"\n"
+' @import "yes.i.did";';
var setParams = {
referencePath: "deep/nested/file",
adjustPaths: 1,
renderStyles: 1
};
var adjustedCss;
// hijack internals to snatch the styles before they are inserted to DOM (DOM messes formating)
var oldFunc = setter2._renderStyles;
console.log("in cssPathAdjustments, returning function");
setter2._renderStyles = function(styles){
adjustedCss = styles.join();
};
console.log("in cssPathAdjustments, calling set");
setter2.set('<style>'+cssText+'</style>', setParams);
console.log("in cssPathAdjustments, done calling set");
setter2._renderStyles = oldFunc;
adjustedCss = adjustedCss.split("\n");
var expectedCss = (".easy{ background-image:url(deep/nested/images/image.png) }\n"
+".dontReplaceEasy{ background-image:url(deep/nested/images/images/image.png) }\n"
+".hardurl{background-image:url(source/~test/%20t'e(s)t.gif(\"1')?foo=bar11103&bar=baz-foo);}body{};\n"
+".file{background-image: url(file:///home/nobody/image.png);}\n"
+".http{background-image: url(http://dojotoolkit.org/image.png);}\n"
+".https{background-image: url(https://dojotoolkit.org/image.png);}\n"
+".nonRelative{background-image:url(/toplevelfolder/image.gif);}\n"
+"@import \"deep/nested/css/main.css\";\n@import \"deep/nested/css/Newbee Url.css\"\t;\n"
+"@import 'http://dojotoolkit.org/dojo.css';\n"
+" @import \"deep/nested/you/never/thought/\" print;\n"
+' @import url(deep/nested/it/would/work) tv, screen;'+"\n"
+' @import url(/did/you/now.css);'+"\n"
+' @import "deep/nested/yes.i.did";').split("\n");
// we split and loop to get a faster hint of where it failed
for(var i = 0; i < expectedCss.length; i++){
t.assertEqual(expectedCss[i], adjustedCss[i]);
}
}
FAILED test: cssPathAdjustments 11 ms
pathAdjustments: htmlPathAdjustments
pathAdjustments: htmlPathAdjustments: requesting content
pathAdjustments: htmlPathAdjustments, handling response
Hover over HTML elements in the main page. Click to hold selection.