@@ -314,6 +314,7 @@ const Buffer = Module("buffer", {
314
314
* buffer. Only returns style sheets for the 'screen' media type.
315
315
*/
316
316
get alternateStyleSheets ( ) {
317
+ // NOTE: getAllStyleSheets seems to be not supported
317
318
let stylesheets = window . getAllStyleSheets ( config . browser . contentWindow ) ;
318
319
319
320
return stylesheets . filter (
@@ -1371,7 +1372,17 @@ const Buffer = Module("buffer", {
1371
1372
styles [ style . title ] . push ( style . href || "inline" ) ;
1372
1373
} ) ;
1373
1374
1374
- context . completions = [ [ s , styles [ s ] . join ( ", " ) ] for ( s in styles ) ] ;
1375
+ // NOTE: was unable to execute this assert
1376
+ /* assert start */
1377
+ // function assert(condition, bookmark) { dump(bookmark+': '); if (!condition) dump('FAILED\n'); else dump('PASSED\n'); }
1378
+ //
1379
+ // let before = [[s, styles[s].join(", ")] for (s in styles)];
1380
+ // let after = Object.keys(styles).map(s => [s, styles[s].join(", ")]);
1381
+ //
1382
+ // assert(JSON.stringify(before) == JSON.stringify(after), '#1 in buffer.js');
1383
+ /* assert end */
1384
+
1385
+ context . completions = Object . keys ( styles ) . map ( s => [ s , styles [ s ] . join ( ", " ) ] ) ;
1375
1386
} ;
1376
1387
1377
1388
const UNTITLED_LABEL = "( Untitled ) ";
@@ -1457,7 +1468,18 @@ const Buffer = Module("buffer", {
1457
1468
1458
1469
if ( flags & this . buffer . VISIBLE ) {
1459
1470
context . title = [ "Buffers" ] ;
1460
- context . completions = [ item for ( item in generateTabs ( tabs || config . tabbrowser . visibleTabs ) ) ] ;
1471
+
1472
+ /* assert start */
1473
+ // function assert(condition, bookmark) { dump(bookmark+': '); if (!condition) dump('FAILED\n'); else dump('PASSED\n'); }
1474
+ //
1475
+ // let before = [item for (item in generateTabs(tabs || config.tabbrowser.visibleTabs))];
1476
+ // let after = Array.from(generateTabs(tabs || config.tabbrowser.visibleTabs));
1477
+ //
1478
+ // dump(JSON.stringify(before));
1479
+ // assert(JSON.stringify(before) == JSON.stringify(after), '#2 in buffer.js');
1480
+ /* assert end */
1481
+
1482
+ context . completions = Array . from ( generateTabs ( tabs || config . tabbrowser . visibleTabs ) ) ;
1461
1483
}
1462
1484
1463
1485
if ( ! liberator . has ( "tabgroup" ) || ! tabGroup . TV )
@@ -1472,7 +1494,7 @@ const Buffer = Module("buffer", {
1472
1494
let groupName = group . getTitle ( ) ;
1473
1495
context . fork ( "GROUP_" + group . id , 0 , this , function ( context ) {
1474
1496
context . title = [ groupName || UNTITLED_LABEL ] ;
1475
- context . completions = [ item for ( item in generateGroupList ( group , groupName ) ) ] ;
1497
+ context . completions = Array . from ( generateGroupList ( group , groupName ) ) ;
1476
1498
} ) ;
1477
1499
}
1478
1500
}
@@ -1670,9 +1692,29 @@ const Buffer = Module("buffer", {
1670
1692
"textarea[not(@disabled) and not(@readonly)]" ,
1671
1693
"iframe" ] ;
1672
1694
1673
- let elements = [ m for ( m in util . evaluateXPath ( xpath ) )
1674
- if ( m . getClientRects ( ) . length && ( ! ( m instanceof HTMLIFrameElement ) || Editor . windowIsEditable ( m . contentWindow ) ) )
1675
- ] ;
1695
+ /* assert start */
1696
+ // function assert(condition, bookmark) { dump(bookmark+': '); if (!condition) dump('FAILED\n'); else dump('PASSED\n'); }
1697
+ //
1698
+ // let after = [];
1699
+ // for (m in util.evaluateXPath(xpath)) {
1700
+ // if (m.getClientRects().length
1701
+ // && (!(m instanceof HTMLIFrameElement) || Editor.windowIsEditable(m.contentWindow)))
1702
+ // after.push(m);
1703
+ // }
1704
+ // let before = [m for (m in util.evaluateXPath(xpath))
1705
+ // if(m.getClientRects().length && (!(m instanceof HTMLIFrameElement) || Editor.windowIsEditable(m.contentWindow)))
1706
+ // ];
1707
+ //
1708
+ // assert(JSON.stringify(before) == JSON.stringify(after), '#3 in buffer.js');
1709
+ /* assert end */
1710
+
1711
+ // NOTE: Array.from doesn't work here
1712
+ let elements = [ ] ;
1713
+ for ( let m in util . evaluateXPath ( xpath ) ) {
1714
+ if ( m . getClientRects ( ) . length
1715
+ && ( ! ( m instanceof HTMLIFrameElement ) || Editor . windowIsEditable ( m . contentWindow ) ) )
1716
+ elements . push ( m ) ;
1717
+ }
1676
1718
1677
1719
liberator . assert ( elements . length > 0 ) ;
1678
1720
buffer . focusElement ( elements [ util . Math . constrain ( count , 1 , elements . length ) - 1 ] ) ;
@@ -1795,7 +1837,18 @@ const Buffer = Module("buffer", {
1795
1837
"Desired info in the :pageinfo output" ,
1796
1838
"charlist" , "gfm" ,
1797
1839
{
1798
- completer : function ( context ) [ [ k , v [ 1 ] ] for ( [ k , v ] in Iterator ( buffer . pageInfo ) ) ]
1840
+ completer : function ( context ) {
1841
+ /* assert start */
1842
+ // function assert(condition, bookmark) { dump(bookmark+': '); if (!condition) dump('FAILED\n'); else dump('PASSED\n'); }
1843
+ //
1844
+ // let before = [[k, v[1]] for ([k, v] in Iterator(buffer.pageInfo))];
1845
+ // let after = Object.keys(buffer.pageInfo).map(k => [k, buffer.pageInfo[k][1]]);
1846
+ //
1847
+ // assert(JSON.stringify(before) == JSON.stringify(after), '#4 in buffer.js');
1848
+ /* assert end */
1849
+
1850
+ return Object . keys ( buffer . pageInfo ) . map ( k => [ k , buffer . pageInfo [ k ] [ 1 ] ] ) ;
1851
+ }
1799
1852
} ) ;
1800
1853
1801
1854
options . add ( [ "scroll" , "scr" ] ,
0 commit comments