@@ -494,8 +494,22 @@ describe('axe.utils.getSelector', function() {
494
494
img2 . setAttribute ( 'src' , '//deque.com/logo.png' ) ;
495
495
496
496
fixtureSetup ( [ link1 , link2 , img1 , img2 ] ) ;
497
- assert . equal ( axe . utils . getSelector ( link2 ) , 'a[href$="about/"]' ) ;
498
- assert . equal ( axe . utils . getSelector ( img2 ) , 'img[src$="logo.png"]' ) ;
497
+ assert . equal ( axe . utils . getSelector ( link2 ) , 'a[href$="about\\/"]' ) ;
498
+ assert . equal ( axe . utils . getSelector ( img2 ) , 'img[src$="logo\\.png"]' ) ;
499
+ } ) ;
500
+
501
+ it ( 'should escape href attributes' , function ( ) {
502
+ var link1 = document . createElement ( 'a' ) ;
503
+ link1 . setAttribute ( 'href' , '//deque.com/about/' ) ;
504
+
505
+ var link2 = document . createElement ( 'a' ) ;
506
+ link2 . setAttribute ( 'href' , '//deque.com/child/ \n\n\n' ) ;
507
+
508
+ fixtureSetup ( [ link1 , link2 ] ) ;
509
+ assert . equal (
510
+ axe . utils . getSelector ( link2 ) ,
511
+ 'a[href="\\/\\/deque\\.com\\/child\\/\\ \\a \\a \\a "]'
512
+ ) ;
499
513
} ) ;
500
514
501
515
it ( 'should not generate universal selectors' , function ( ) {
@@ -516,8 +530,11 @@ describe('axe.utils.getSelector', function() {
516
530
node2 . setAttribute ( 'href' , href2 ) ;
517
531
fixtureSetup ( [ node1 , node2 ] ) ;
518
532
519
- assert . include ( axe . utils . getSelector ( node1 ) , href1 ) ;
520
- assert . include ( axe . utils . getSelector ( node2 ) , href2 ) ;
533
+ assert . include ( axe . utils . getSelector ( node1 ) , 'mars2\\.html\\?a\\=be_bold' ) ;
534
+ assert . include (
535
+ axe . utils . getSelector ( node2 ) ,
536
+ 'mars2\\.html\\?a\\=be_italic'
537
+ ) ;
521
538
} ) ;
522
539
523
540
// shadow DOM v1 - note: v0 is compatible with this code, so no need
0 commit comments