File tree Expand file tree Collapse file tree
Source/WebInspectorUI/UserInterface/Base Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -226,13 +226,27 @@ if (!window.InspectorFrontendHost) {
226226
227227 canSave ( saveMode )
228228 {
229- return false ;
229+ return true ;
230230 }
231231
232232 save ( saveDatas , forceSaveAs )
233233 {
234- // FIXME: Create a Blob from the content, get an object URL, open it to trigger a download.
235- throw "unimplemented" ;
234+ for ( let saveData of saveDatas ) {
235+ var blob = new Blob ( [ saveData . content ] , { type : "octet/stream" } ) ;
236+ var blobURL = window . URL . createObjectURL ( blob ) ;
237+
238+ var a = document . createElement ( "a" ) ;
239+ a . href = blobURL ;
240+ a . style . display = "none" ;
241+ // url looks like "web-inspector:///file.ext" use filename only
242+ a . download = saveData . url . split ( '/' ) . pop ( ) ;
243+ // Don't add this element to the DOM to skip custom click handler
244+ // that will remove target file name ('download' attr)
245+ a . click ( ) ;
246+ setTimeout ( ( ) => {
247+ window . URL . revokeObjectURL ( blob ) ;
248+ } , 0 ) ;
249+ }
236250 }
237251
238252 canLoad ( )
You can’t perform that action at this time.
0 commit comments