File tree Expand file tree Collapse file tree 3 files changed +22
-8
lines changed Expand file tree Collapse file tree 3 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -113,14 +113,25 @@ function onLoad() {
113
113
// Hide the tests link if the page isn't available. It may be stripped out
114
114
// of extension packages.
115
115
116
- // Check if our test file exists.
117
- Utils . getLocalFile ( './test/index.html' , 'text' , function ( _ , err ) {
118
- // The test files aren't present, so hide the button.
119
- if ( err ) {
116
+ // Check if our test file exists. Note that we can't use Utils.getLocalFile as it throws
117
+ // an asynchronous error if the file isn't found.
118
+ // TODO: When Utils.getLocalFile is changed to return a promise, use it here.
119
+ fetch ( './test/index.html' )
120
+ . then ( response => {
121
+ if ( ! response . ok ) {
122
+ // The test files aren't present, so hide the button.
123
+ $ ( '#tests-link' ) . hide ( ) ;
124
+ }
125
+ else {
126
+ // When the file is absent, Firefox still gives a 200 status, but will throw an
127
+ // error when the response is read.
128
+ return response . text ( ) ;
129
+ }
130
+ } )
131
+ . catch ( err => {
120
132
// The test files aren't present, so hide the button.
121
133
$ ( '#tests-link' ) . hide ( ) ;
122
- }
123
- } ) ;
134
+ } ) ;
124
135
125
136
// Older Thunderbird may try to open this options page in a new ChromeWindow, and it
126
137
// won't work. So in that case we need to tell the user how they can actually open the
Original file line number Diff line number Diff line change @@ -339,7 +339,10 @@ function getLocalURL(url) {
339
339
// Makes an asynchrous XHR request for a local file (basically a thin wrapper).
340
340
// `dataType` must be one of 'text', 'json', or 'base64'.
341
341
// `callback` will be called with the response value, of a type depending on `dataType`.
342
- // Errors are no expected for local files, and will result in an exception being thrown asynchrously.
342
+ // Errors are not expected for local files, and will result in an exception being thrown asynchrously.
343
+ // TODO: Return a promise instead of using a callback. This will allow returning an error
344
+ // properly, and then this can be used in options.js when checking for the existence of
345
+ // the test file.
343
346
function getLocalFile ( url , dataType , callback ) {
344
347
fetch ( url )
345
348
. then ( response => {
Original file line number Diff line number Diff line change 1
1
{
2
2
"manifest_version" : 3 ,
3
3
"name" : " __MSG_app_name__" ,
4
- "version" : " 2.14.0 " ,
4
+ "version" : " 2.14.1 " ,
5
5
"description" : " __MSG_app_slogan__" ,
6
6
"homepage_url" : " https://markdown-here.com" ,
7
7
"default_locale" : " en" ,
You can’t perform that action at this time.
0 commit comments