2011-02-25 14:12:42 -08:00
/* vim:set ts=2 sw=2 sts=2 et: */
/ * A n y c o p y r i g h t i s d e d i c a t e d t o t h e P u b l i c D o m a i n .
http : //creativecommons.org/publicdomain/zero/1.0/ */
2012-03-24 04:34:42 -07:00
const TEST _URI = 'data:text/html;charset=utf-8,<div style="-moz-opacity:0;">test repeated' +
2011-02-25 14:12:42 -08:00
' css warnings</div><p style="-moz-opacity:0">hi</p>' ;
function onContentLoaded ( )
{
2012-05-10 08:01:37 -07:00
browser . removeEventListener ( "load" , onContentLoaded , true ) ;
2011-02-25 14:12:42 -08:00
2011-07-01 13:03:52 -07:00
let HUD = HUDService . getHudByWindow ( content ) ;
let jsterm = HUD . jsterm ;
let outputNode = HUD . outputNode ;
2011-02-25 14:12:42 -08:00
2012-05-10 08:01:37 -07:00
let cssWarning = "Unknown property '-moz-opacity'. Declaration dropped." ;
2013-04-04 05:41:11 -07:00
let textFound = false ;
let repeats = 0 ;
function displayResults ( )
{
ok ( textFound , "css warning was found" ) ;
is ( repeats , 2 , "The unknown CSS property warning is displayed only once" ) ;
}
2011-02-25 14:12:42 -08:00
2012-05-10 08:01:37 -07:00
waitForSuccess ( {
name : "2 repeated CSS warnings" ,
2013-04-04 05:41:11 -07:00
validatorFn : ( ) => {
let node = outputNode . querySelector ( ".webconsole-msg-cssparser" ) ;
if ( ! node ) {
return false ;
}
textFound = node . textContent . indexOf ( cssWarning ) > - 1 ;
repeats = node . querySelector ( ".webconsole-msg-repeat" )
. getAttribute ( "value" ) ;
return textFound && repeats == 2 ;
2012-05-10 08:01:37 -07:00
} ,
2013-04-04 05:41:11 -07:00
successFn : ( ) => {
displayResults ( ) ;
2012-05-10 08:01:37 -07:00
testConsoleLogRepeats ( ) ;
} ,
2013-04-04 05:41:11 -07:00
failureFn : ( ) => {
displayResults ( ) ;
finishTest ( ) ;
} ,
2012-05-10 08:01:37 -07:00
} ) ;
}
function testConsoleLogRepeats ( )
{
let HUD = HUDService . getHudByWindow ( content ) ;
let jsterm = HUD . jsterm ;
let outputNode = HUD . outputNode ;
2011-02-25 14:12:42 -08:00
jsterm . clearOutput ( ) ;
2011-07-25 06:36:36 -07:00
jsterm . setInputValue ( "for (let i = 0; i < 10; ++i) console.log('this is a line of reasonably long text that I will use to verify that the repeated text node is of an appropriate size.');" ) ;
2011-02-25 14:12:42 -08:00
jsterm . execute ( ) ;
2012-05-10 06:15:10 -07:00
waitForSuccess ( {
2013-04-09 02:46:30 -07:00
timeout : 10000 ,
2012-05-10 06:15:10 -07:00
name : "10 repeated console.log messages" ,
validatorFn : function ( )
{
let node = outputNode . querySelector ( ".webconsole-msg-console" ) ;
return node && node . childNodes [ 3 ] . firstChild . getAttribute ( "value" ) == 10 ;
} ,
successFn : finishTest ,
2013-04-09 02:46:30 -07:00
failureFn : function ( ) {
info ( "output content: " + outputNode . textContent ) ;
finishTest ( ) ;
} ,
2012-05-10 06:15:10 -07:00
} ) ;
2011-02-25 14:12:42 -08:00
}
/ * *
* Unit test for bug 611795 :
* Repeated CSS messages get collapsed into one .
* /
function test ( )
{
addTab ( TEST _URI ) ;
2012-05-10 06:15:10 -07:00
browser . addEventListener ( "load" , function onLoad ( ) {
browser . removeEventListener ( "load" , onLoad , true ) ;
2012-05-10 08:01:37 -07:00
openConsole ( null , function ( aHud ) {
2012-05-10 06:15:10 -07:00
// Clear cached messages that are shown once the Web Console opens.
aHud . jsterm . clearOutput ( true ) ;
browser . addEventListener ( "load" , onContentLoaded , true ) ;
content . location . reload ( ) ;
} ) ;
2011-02-25 14:12:42 -08:00
} , true ) ;
}