@@ -15,7 +15,6 @@ const { fireAPageTransitionEvent } = require("../living/helpers/page-transition-
1515const namedPropertiesWindow = require ( "../living/named-properties-window" ) ;
1616const postMessage = require ( "../living/post-message" ) ;
1717const DOMException = require ( "domexception/webidl2js-wrapper" ) ;
18- const { btoa, atob } = require ( "abab" ) ;
1918const idlUtils = require ( "../living/generated/utils" ) ;
2019const WebSocketImpl = require ( "../living/websockets/WebSocket-impl" ) . implementation ;
2120const BarProp = require ( "../living/generated/BarProp" ) ;
@@ -757,25 +756,27 @@ function Window(options) {
757756 this . postMessage = postMessage ( window ) ;
758757
759758 this . atob = function ( str ) {
760- const result = atob ( str ) ;
761- if ( result === null ) {
759+ try {
760+ return atob ( str ) ;
761+ } catch ( e ) {
762+ // Convert Node.js DOMException to one from our global.
762763 throw DOMException . create ( window , [
763764 "The string to be decoded contains invalid characters." ,
764765 "InvalidCharacterError"
765766 ] ) ;
766767 }
767- return result ;
768768 } ;
769769
770770 this . btoa = function ( str ) {
771- const result = btoa ( str ) ;
772- if ( result === null ) {
771+ try {
772+ return btoa ( str ) ;
773+ } catch ( e ) {
774+ // Convert Node.js DOMException to one from our global.
773775 throw DOMException . create ( window , [
774776 "The string to be encoded contains invalid characters." ,
775777 "InvalidCharacterError"
776778 ] ) ;
777779 }
778- return result ;
779780 } ;
780781
781782 this . stop = function ( ) {
0 commit comments