// Error checking.
if (icon.IsEmpty()) {
- args->ThrowError("icon must be set");
+ args->ThrowError("Must specify non-empty 'icon' option");
return;
}
base::MessageLoop::current());
DragFileItems(files, icon->image(), web_contents()->GetNativeView());
} else {
- args->ThrowError("There is nothing to drag");
+ args->ThrowError("Must specify either 'file' or 'files' option");
}
}
})
w.webContents.inspectElement(10, 10)
})
+
+ describe('startDrag({file, icon})', () => {
+ it('throws errors for a missing file or a missing/empty icon', () => {
+ assert.throws(() => {
+ w.webContents.startDrag({icon: path.join(__dirname, 'fixtures', 'assets', 'logo.png')})
+ }, /Must specify either 'file' or 'files' option/)
+
+ assert.throws(() => {
+ w.webContents.startDrag({file: __filename, icon: __filename})
+ }, /Must specify non-empty 'icon' option/)
+
+ assert.throws(() => {
+ w.webContents.startDrag({file: __filename})
+ }, /Must specify non-empty 'icon' option/)
+ })
+ })
})