mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
Make $window testable.
This commit is contained in:
parent
329fedbcc6
commit
0ddc1eb0b0
1 changed files with 7 additions and 7 deletions
|
@ -17,7 +17,7 @@ module.exports = function deviceContextMenuDirective($window) {
|
||||||
|
|
||||||
function saveToDisk(fileURL, fileName) {
|
function saveToDisk(fileURL, fileName) {
|
||||||
// for non-IE
|
// for non-IE
|
||||||
if (!window.ActiveXObject) {
|
if (!$window.ActiveXObject) {
|
||||||
var save = document.createElement('a')
|
var save = document.createElement('a')
|
||||||
save.href = fileURL
|
save.href = fileURL
|
||||||
save.target = '_blank'
|
save.target = '_blank'
|
||||||
|
@ -26,16 +26,16 @@ module.exports = function deviceContextMenuDirective($window) {
|
||||||
var event = document.createEvent('Event')
|
var event = document.createEvent('Event')
|
||||||
event.initEvent('click', true, true)
|
event.initEvent('click', true, true)
|
||||||
save.dispatchEvent(event)
|
save.dispatchEvent(event)
|
||||||
if (window.URL) {
|
if ($window.URL) {
|
||||||
window.URL.revokeObjectURL(save.href)
|
$window.URL.revokeObjectURL(save.href)
|
||||||
} else if (window.webkitURL) {
|
} else if ($window.webkitURL) {
|
||||||
window.webkitURL.revokeObjectURL(save.href)
|
$window.webkitURL.revokeObjectURL(save.href)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for IE
|
// for IE
|
||||||
else if (!!window.ActiveXObject && document.execCommand) {
|
else if (!!$window.ActiveXObject && document.execCommand) {
|
||||||
var _window = window.open(fileURL, '_blank')
|
var _window = $window.open(fileURL, '_blank')
|
||||||
_window.document.close()
|
_window.document.close()
|
||||||
_window.document.execCommand('SaveAs', true, fileName || fileURL)
|
_window.document.execCommand('SaveAs', true, fileName || fileURL)
|
||||||
_window.close()
|
_window.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue