|
27 | 27 | define(function (require, exports, module) { |
28 | 28 | "use strict"; |
29 | 29 |
|
30 | | - var SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils"), |
31 | | - FileUtils = brackets.getModule("file/FileUtils"); |
| 30 | + var SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils"), |
| 31 | + FileUtils = brackets.getModule("file/FileUtils"), |
| 32 | + PreferencesManager = brackets.getModule("preferences/PreferencesManager"), |
| 33 | + prefs = PreferencesManager.getExtensionPrefs("quickview"); |
32 | 34 |
|
33 | 35 | describe("Quick View", function () { |
34 | 36 | var testFolder = FileUtils.getNativeModuleDirectoryPath(module) + "/unittest-files/"; |
@@ -472,6 +474,57 @@ define(function (require, exports, module) { |
472 | 474 | checkImagePathAtPos("img/don't.png", 184, 26); // url("") containing ' |
473 | 475 | checkImageDataAtPos("data:image/svg+xml;utf8, <svg version='1.1' xmlns='http://www.w3.org/2000/svg'></svg>", 185, 26); // data url("") containing ' |
474 | 476 | }); |
| 477 | + |
| 478 | + it("Should show image preview for URLs with known image extensions", function() { |
| 479 | + checkImageDataAtPos("http://example.com/image.gif", 194, 20); |
| 480 | + checkImageDataAtPos("http://example.com/image.png", 195, 20); |
| 481 | + checkImageDataAtPos("http://example.com/image.jpe", 196, 20); |
| 482 | + checkImageDataAtPos("http://example.com/image.jpeg", 197, 20); |
| 483 | + checkImageDataAtPos("http://example.com/image.jpg", 198, 20); |
| 484 | + checkImageDataAtPos("http://example.com/image.ico", 199, 20); |
| 485 | + checkImageDataAtPos("http://example.com/image.bmp", 200, 20); |
| 486 | + checkImageDataAtPos("http://example.com/image.svg", 201, 20); |
| 487 | + }); |
| 488 | + |
| 489 | + it("Should show image preview for extensionless URLs (with protocol) with pref set", function() { |
| 490 | + // Flip the pref on and restore when done |
| 491 | + var original = prefs.get("extensionlessImagePreview"); |
| 492 | + prefs.set("extensionlessImagePreview", true); |
| 493 | + |
| 494 | + checkImageDataAtPos("https://image.service.com/id/1234513", 203, 20); // https |
| 495 | + checkImageDataAtPos("http://image.service.com/id/1234513", 204, 20); // http |
| 496 | + checkImageDataAtPos("https://image.service.com/id/1234513?w=300&h=400", 205, 20); // qs params |
| 497 | + |
| 498 | + prefs.set("extensionlessImagePreview", original); |
| 499 | + }); |
| 500 | + |
| 501 | + it("Should not show image preview for extensionless URLs (with protocol) without pref set", function() { |
| 502 | + // Flip the pref off and restore when done |
| 503 | + var original = prefs.get("extensionlessImagePreview"); |
| 504 | + prefs.set("extensionlessImagePreview", false); |
| 505 | + |
| 506 | + checkImageDataAtPos("https://image.service.com/id/1234513", 203, 20); // https |
| 507 | + checkImageDataAtPos("http://image.service.com/id/1234513", 204, 20); // http |
| 508 | + checkImageDataAtPos("https://image.service.com/id/1234513?w=300&h=400", 205, 20); // qs params |
| 509 | + |
| 510 | + prefs.set("extensionlessImagePreview", original); |
| 511 | + }); |
| 512 | + |
| 513 | + it("Should ignore URLs for common non-image extensions", function() { |
| 514 | + expectNoPreviewAtPos(209, 20); // .html |
| 515 | + expectNoPreviewAtPos(210, 20); // .css |
| 516 | + expectNoPreviewAtPos(211, 20); // .js |
| 517 | + expectNoPreviewAtPos(212, 20); // .json |
| 518 | + expectNoPreviewAtPos(213, 20); // .md |
| 519 | + expectNoPreviewAtPos(214, 20); // .xml |
| 520 | + expectNoPreviewAtPos(215, 20); // .mp3 |
| 521 | + expectNoPreviewAtPos(216, 20); // .ogv |
| 522 | + expectNoPreviewAtPos(217, 20); // .mp4 |
| 523 | + expectNoPreviewAtPos(218, 20); // .mpeg |
| 524 | + expectNoPreviewAtPos(219, 20); // .webm |
| 525 | + expectNoPreviewAtPos(220, 20); // .zip |
| 526 | + expectNoPreviewAtPos(221, 20); // .tgz |
| 527 | + }); |
475 | 528 |
|
476 | 529 | it("Should show image preview for a data URI inside url()", function () { |
477 | 530 | runs(function () { |
|
0 commit comments