/usr/share/pyshared/slimmer/tests/codechunks.py is in python-slimmer 0.1.30-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | #-*- coding: utf-8 -*
CSS_1 = '''
/* Comment 1 */
div#main {
font-family: Verdana, "Courier New" ;
}
h2 {
/* Comment 2 */
font-size: 10px;
}
'''
expect_CSS_1 = '''
div#main{font-family:Verdana,"Courier New"}h2{font-size:10px}
'''
#----------------------------------------------------------------------------
CSS_2 = '''
<style type="text/css">
div#main {
font-family: Verdana, "Courier New" ;
}
h2 {
font-size: 10px;
}
</style>
'''
expect_CSS_2 = '''
<style type="text/css">
div#main{font-family:Verdana,"Courier New"}h2{font-size:10px}</style>
'''
#----------------------------------------------------------------------------
CSS_3 = r'''
#centercontent {
border:1px solid #000000;
voice-family: "\"}\"";
voice-family: inherit;
margin-left: 201px;
}
'''
expect_CSS_3 = r'''
#centercontent{border:1px solid #000;voice-family: "\"}\"";voice-family:inherit;margin-left:201px}
'''
#----------------------------------------------------------------------------
CSS_3b = unicode(CSS_3)
expect_CSS_3b = unicode(expect_CSS_3)
#----------------------------------------------------------------------------
CSS_3c = u'''
body {
color:#000000;
color:#ccFF99;
\xa3
}
'''
expect_CSS_3c = u'''
body{color:#000;color:#cF9;\xa3}'''
#----------------------------------------------------------------------------
CSS_4 = r'''
p { color:#123456; }
select {
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 11px;
color: #000000;
/*
background-color: #FFFFFF;
*/
}
#myDiv { float: left; background: transparent; }
'''
expect_CSS_4 = r'''
p{color:#123456}select{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;color:#000}#myDiv{float:left;background:transparent}
'''
#----------------------------------------------------------------------------
CSS_5 = r'''
/* remove this comment */
#isnotMacIE5 { display: none; }
#isMacIE5 { display: block; background-color: #060; color: #fff; }
/* commented backslash hack v2 \*/
#isnotMacIE5 { display: block; background-color: #060; color: #fff; }
#isMacIE5 { display: none; }
/* keep this comment */
#ismozilla { state: cool; }
/* safely remove this one too */
'''
expect_CSS_5 = r'''
#isnotMacIE5{display:none}#isMacIE5{display:block;background-color:#060;color:#fff}/* commented backslash hack v2 \*/
#isnotMacIE5{display:block;background-color:#060;color:#fff}#isMacIE5{display:none}/* keep this comment */
#ismozilla{state:cool}
'''
#----------------------------------------------------------------------------
CSS_6 = r'''
div a {display:block;}
'''
expect_CSS_6 = r'''
div a{display:block}
'''
#----------------------------------------------------------------------------
CSS_7 = r'''
/* Holly hack to cure peek-a-boo IE 6 bug*/
/* Hides from IE5-mac \*/
* html #region-content {height: 1%;}
/* End hide from IE5-mac */
'''
expect_CSS_7 = r'''
/* Hides from IE5-mac \*/
* html #region-content{height:1%}/* End hide from IE5-mac */
'''
#----------------------------------------------------------------------------
HTML_1='''
<img src="a.gif" width="100" width="100" height='100' border=0>
<STYLE type="text/css">
div#main {
font-family:Verdana, "Courier New" ;
}
</style>
<pre>
Here
width="100"
</pre>
'''
expect_HTML_1='''
<img src="a.gif" width="100" width="100" height='100' border=0><STYLE type="text/css">
div#main{font-family:Verdana,"Courier New"}</style><pre>
Here
width="100"
</pre>
'''
#----------------------------------------------------------------------------
HTML_2='''
<a href="x"
width="100%" border='0'>Pointless extra
space</a>
<!-- one line comment -->
<!-- two line
comment -->
<script language="Javascript">
<!-- hide this
function foo() {
alert("Hell");
}
//-->
</script>
'''
expect_HTML_2='''
<a href="x" width="100%" border='0'>Pointless extra
space</a><!-- two line
comment --><script language="Javascript"><!--
function foo(){alert("Hell");}
//--></script>
'''
#----------------------------------------------------------------------------
HTML_3='''
<input value=" OK " >
<img alt=' hej ' title=" Bajs " width=32 >
<a href="x" width="100%" border=0>Pointless extra
space</a>
<img src='blank.gif'
border='0' height='32' alt='' width='32'>
'''
expect_HTML_3='''
<input value=" OK "><img alt=' hej ' title=" Bajs " width=32 ><a href="x" width="100%" border=0>Pointless extra
space</a><img src='blank.gif' border='0' height='32' alt='' width='32'>
'''
#----------------------------------------------------------------------------
HTML_4='''<script>
if (isMozi) {
slides = slideml.doc.getElementsByTagNameNS("http://www.oscom.org/2003/SlideML/1.0/","slide");
}
else {
slides = slideml.doc.getElementsByTagName("s:slide");
}
</script>'''
expect_HTML_4 = '''<script>if(isMozi){slides=slideml.doc.getElementsByTagNameNS("http://www.oscom.org/2003/SlideML/1.0/","slide");}else{slides=slideml.doc.getElementsByTagName("s:slide");}
</script>'''
#----------------------------------------------------------------------------
HTML_5='''<img src="/p_/sp" width="2" height="1" alt="" />'''
expect_HTML_5='''<img src="/p_/sp" width="2" height="1" alt="" />'''
#----------------------------------------------------------------------------
HTML_6='''
<style type="text/css"><!--
div.commentinline {
font-family:Arial, Verdana, sans-serif;
border-top:1px solid #cccccc;
padding:3px 4px 4px 4px;
margin-top:10px;
margin-bottom:10px;
margin-left:15px;
}
//--></style>
'''
expect_HTML_6='''
<style type="text/css"><!--
div.commentinline{font-family:Arial,Verdana,sans-serif;border-top:1px solid #ccc;padding:3px 4px 4px 4px;margin-top:10px;margin-bottom:10px;margin-left:15px}
//--></style>'''
#----------------------------------------------------------------------------
HTML_7='''
<html>
<!--#include virtual="/include/myinclude.asp"-->
<body>
</body>
</html>
'''
expect_HTML_7='''
<html><!--#include virtual="/include/myinclude.asp"--><body></body></html>
'''
#----------------------------------------------------------------------------
HTML_8=u'''
<html>
<style>
* { color:#000000; background-color:#ffcc99 ; }
</style>
<body>
<div style="color:#CCCCCC; background-color: #ee99cc">Pay with \xa3</div>
</body>
</html>
'''
expect_HTML_8=u'''
<html><style> *{color:#000;background-color:#fc9}</style><body><div style="color:#CCCCCC; background-color: #ee99cc">Pay with \xa3</div></body></html>
'''
#----------------------------------------------------------------------------
HTML_9=u'''
<html>
<style>
* { color:#000000;
background-color:#ffcc99 ;
}
</style>
<body>
<div style="color:#CCCCCC; background-color: #ee99cc">Pay with \xa3</div>
</body>
</html>
'''
expect_HTML_9=u'''
<html><style> *{color:#000;background-color:#fc9}</style><body><div style="color:#CCCCCC; background-color: #ee99cc">Pay with \xa3</div></body></html>
'''
#----------------------------------------------------------------------------
JS_1='''
init = function() {
foo();
bar();
}
window.onload = init;
'''
expect_JS_1='''
init=function(){foo();bar();}
window.onload=init;
'''
#----------------------------------------------------------------------------
JS_2='''
function econvert(s) {
s=s.replace(/%7E/g,'~');
s=s.replace(/%28/g,'(');
s=s.replace(/%29/g,')');
s=s.replace(/%20/g,' ');
s=s.replace(/_dot_| dot |_\._|\(\.\)/gi, '.');
s=s.replace(/_at_|~at~/gi, '@');
return s;
}
function AEHit() {
var ss = document.getElementsByTagName("span");
for (i=0; i< ss.length; i++)
if (ss[i].className=="aeh")
ss[i].innerHTML = econvert(ss[i].innerHTML);
}
'''
expect_JS_2='''
function econvert(s){s=s.replace(/%7E/g,'~');s=s.replace(/%28/g,'(');
s=s.replace(/%29/g,')');s=s.replace(/%20/g,' ');s=s.replace(/_dot_| dot |_\._|\(\.\)/gi, '.');s=s.replace(/_at_|~at~/gi, '@');return s;}
function AEHit(){var ss=document.getElementsByTagName("span");for (i=0;i< ss.length;i++)if(ss[i].className=="aeh")
ss[i].innerHTML=econvert(ss[i].innerHTML);}
'''
#----------------------------------------------------------------------------
JS_3='''
var x = " ";
x +="nothing";
x+= "something";
x+="anything";
y = 10;
y +=1;
y+= 1;
y+=1;
y +=15;
y+= 15;
y+=15;
'''
expect_JS_3='''
var x=" ";x+="nothing";x+="something";x+="anything";
y=10;y+=1;y+=1;y+=1;
y+=15;y+=15;y+=15;
'''
#----------------------------------------------------------------------------
JS_4 ='''
this.onLoad = true;
this.onLoaded = false;
var x = true;
'''
expect_JS_4 ='''
this.onLoad=true;this.onLoaded=false;var x=true;
'''
#----------------------------------------------------------------------------
JS_5 ='''
if (document.getElementById("someting")) {
cool();
} else if (document.getElementById("elsething")) {
wicked();
} else {
poor();
}
'''
expect_JS_5 ='''
if(document.getElementById("someting")){cool();}else if(document.getElementById("elsething")){wicked();}else{poor();}
'''
#----------------------------------------------------------------------------
# function foo() { alert( "foo" ); }
JS_6 ='''
bar = function () { alert( "bar" ); }
bar2 = function() { alert( "bar2" ); }
'''
# function foo(){alert( "foo" );}
expect_JS_6 ='''
bar=function(){alert( "bar" );}
bar2=function(){alert( "bar2" );}
'''
#----------------------------------------------------------------------------
# testing local variables inside functions
JS_7 ='''
function foobar(x,y) {
var element1 = document.getElementById('something');
alert(element1);
}
'''
# function foo(){alert( "foo" );}
expect_JS_7 ='''
function foobar(x,y) {
var e = document.getElementById('something');
alert(e);
}
'''
#----------------------------------------------------------------------------
# comments within the code
JS_8 ='''
function foobar(x,y) {
var element1 = document.getElementById('something'); // alert(element1);
alert(element1); // this can be removed
} // end of function;
'''
expect_JS_8 ='''
function foobar(x,y){var element1=document.getElementById('something');alert(element1);}
'''
#----------------------------------------------------------------------------
#
JS_9 ='''
function nodeContained(innernode, outernode){
// check if innernode is contained in outernode
var node = innernode.parentNode;
while (node != document) {
if (node == outernode) {
return true;
}
node=node.parentNode;
}
return false;
};
'''
expect_JS_9 ='''
function nodeContained(innernode,outernode){var node=innernode.parentNode;while(node!=document){if(node==outernode) {return true;}
node=node.parentNode;}
return false;};
'''
#----------------------------------------------------------------------------
#
JS_10 ='''
// Insert P element
if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
// Insert P element instead of BR
if (tinyMCE.selectedInstance._insertPara(e)) {
// Cancel event
tinyMCE.execCommand("mceAddUndoLevel");
tinyMCE.cancelEvent(e);
return false;
}
}
'''
expect_JS_10 ='''
if(tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey){if(tinyMCE.selectedInstance._insertPara(e)) {tinyMCE.execCommand("mceAddUndoLevel");tinyMCE.cancelEvent(e);
return false;}}
'''
JS_11 = '''
ajax = Class.create();
ajax.prototype = {
initialize: function(url, options){
this.transport = this.getTransport();
this.postBody = options.postBody || '';
this.method = options.method || 'post';
this.onComplete = options.onComplete || null;
this.update = $(options.update) || null;
this.request(url);
},
request: function(url){
this.transport.open(this.method, url, true);
this.transport.onreadystatechange = this.onStateChange.bind(this);
if (this.method == 'post') {
this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
}
this.transport.send(this.postBody);
},
onStateChange: function(){
if (this.transport.readyState == 4 && this.transport.status == 200) {
if (this.onComplete)
setTimeout(function(){this.onComplete(this.transport);}.bind(this), 10);
if (this.update)
setTimeout(function(){this.update.innerHTML = this.transport.responseText;}.bind(this), 10);
this.transport.onreadystatechange = function(){};
}
},
getTransport: function() {
if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else return false;
}
};
'''
expect_JS_11 ='''
ajax=Class.create();ajax.prototype = {initialize: function(url,options){this.transport=this.getTransport();this.postBody=options.postBody || '';this.method=options.method || 'post';this.onComplete=options.onComplete || null;this.update = $(options.update) || null;this.request(url);},
request: function(url){this.transport.open(this.method, url, true);this.transport.onreadystatechange=this.onStateChange.bind(this);if(this.method=='post'){this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');if(this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');}
this.transport.send(this.postBody);},
onStateChange: function(){if(this.transport.readyState == 4 && this.transport.status == 200) {if(this.onComplete)
setTimeout(function(){this.onComplete(this.transport);}.bind(this),10);if(this.update)
setTimeout(function(){this.update.innerHTML=this.transport.responseText;}.bind(this),10);this.transport.onreadystatechange=function(){};}},
getTransport: function(){if(window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');else if(window.XMLHttpRequest) return new XMLHttpRequest();else return false;}};
'''
expect_JS_11_hardcore ='''
ajax=Class.create();ajax.prototype = {initialize: function(_0,_1){this.transport=this.getTransport();this.postBody=_1.postBody || '';this.method=_1.method || 'post';this.onComplete=_1.onComplete || null;this.update = $(_1.update) || null;this.request(_0);},
request: function(_0){this.transport.open(this.method, _0, true);this.transport.onreadystatechange=this.onStateChange.bind(this);if(this.method=='post'){this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');if(this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');}
this.transport.send(this.postBody);},
onStateChange: function(){if(this.transport.readyState == 4 && this.transport.status == 200) {if(this.onComplete)
setTimeout(function(){this.onComplete(this.transport);}.bind(this),10);if(this.update)
setTimeout(function(){this.update.innerHTML=this.transport.responseText;}.bind(this),10);this.transport.onreadystatechange=function(){};}},
getTransport: function(){if(window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');else if(window.XMLHttpRequest) return new XMLHttpRequest();else return false;}};
'''
#----------------------------------------------------------------------------
JS_12='''
function foo(documentnode, nodevalue) {
return documentnode + nodevalue;
}
'''
expect_JS_12='''
function foo(documentnode,nodevalue){return documentnode + nodevalue;}
'''
expect_JS_12_hardcore='''
function foo(_0,_1){return _0 + _1;}
'''
#----------------------------------------------------------------------------
JS_13 = '''
addEvent(window, 'load', function(){
var editlinks = getElementsByClass("edit", document, "img");
for (var e in editlinks) {
foo();
}
});
'''
expect_JS_13 = '''
addEvent(window, 'load', function(){var editlinks=getElementsByClass("edit", document, "img");for(var e in editlinks){foo();}});
'''
#----------------------------------------------------------------------------
JS_14 = '''
function (variable1, variable2) {
if (variable1 == variable2) {
return true;
} else {
return false;
}
}'''
expect_JS_14 = '''
function (variable1,variable2) {if(variable1==variable2){return true;}else{return false;}}
'''
expect_JS_14_hardcore = '''
function (_0,_1) {if(_0==_1){return true;}else{return false;}}
'''
#----------------------------------------------------------------------------
JS_15 = '''
var x =1
if (x==1) {
x=2;
}'''
expect_JS_15 = '''
var x=1if(x==1){x=2;}
'''
#----------------------------------------------------------------------------
JS_16 = '''
var uk_counties = ['a', 'b', 'c'];
var uk__9123 = ['a', 'b', 'c'];
var uk = ['a', 'b', 'c'];
var uk_counties = ["a", "b", "c"];
var uk__9123 = ["a", "b", "c"];
var uk = ["a", "b", "c"];
'''
expect_JS_16 = '''
var uk_counties=['a', 'b', 'c'];var uk__9123=['a', 'b', 'c'];var uk=['a', 'b', 'c'];var uk_counties=["a", "b", "c"];var uk__9123=["a", "b", "c"];var uk=["a", "b", "c"];
'''
|