|
1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 // Tests to make sure that URLs are clickable in the rule view |
|
8 |
|
9 const TEST_URI = TEST_URL_ROOT + "doc_urls_clickable.html"; |
|
10 const TEST_IMAGE = TEST_URL_ROOT + "doc_test_image.png"; |
|
11 const BASE_64_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; |
|
12 |
|
13 let test = asyncTest(function*() { |
|
14 yield addTab(TEST_URI); |
|
15 let {toolbox, inspector, view} = yield openRuleView(); |
|
16 yield selectNodes(inspector, view); |
|
17 }); |
|
18 |
|
19 function* selectNodes(inspector, ruleView) { |
|
20 let relative1 = ".relative1"; |
|
21 let relative2 = ".relative2"; |
|
22 let absolute = ".absolute"; |
|
23 let inline = ".inline"; |
|
24 let base64 = ".base64"; |
|
25 let noimage = ".noimage"; |
|
26 let inlineresolved = ".inline-resolved"; |
|
27 |
|
28 yield selectNode(relative1, inspector); |
|
29 let relativeLink = ruleView.doc.querySelector(".ruleview-propertycontainer a"); |
|
30 ok(relativeLink, "Link exists for relative1 node"); |
|
31 is(relativeLink.getAttribute("href"), TEST_IMAGE, "href matches"); |
|
32 |
|
33 yield selectNode(relative2, inspector); |
|
34 let relativeLink = ruleView.doc.querySelector(".ruleview-propertycontainer a"); |
|
35 ok(relativeLink, "Link exists for relative2 node"); |
|
36 is(relativeLink.getAttribute("href"), TEST_IMAGE, "href matches"); |
|
37 |
|
38 yield selectNode(absolute, inspector); |
|
39 let absoluteLink = ruleView.doc.querySelector(".ruleview-propertycontainer a"); |
|
40 ok(absoluteLink, "Link exists for absolute node"); |
|
41 is(absoluteLink.getAttribute("href"), TEST_IMAGE, "href matches"); |
|
42 |
|
43 yield selectNode(inline, inspector); |
|
44 let inlineLink = ruleView.doc.querySelector(".ruleview-propertycontainer a"); |
|
45 ok(inlineLink, "Link exists for inline node"); |
|
46 is(inlineLink.getAttribute("href"), TEST_IMAGE, "href matches"); |
|
47 |
|
48 yield selectNode(base64, inspector); |
|
49 let base64Link = ruleView.doc.querySelector(".ruleview-propertycontainer a"); |
|
50 ok(base64Link, "Link exists for base64 node"); |
|
51 is(base64Link.getAttribute("href"), BASE_64_URL, "href matches"); |
|
52 |
|
53 yield selectNode(inlineresolved, inspector); |
|
54 let inlineResolvedLink = ruleView.doc.querySelector(".ruleview-propertycontainer a"); |
|
55 ok(inlineResolvedLink, "Link exists for style tag node"); |
|
56 is(inlineResolvedLink.getAttribute("href"), TEST_IMAGE, "href matches"); |
|
57 |
|
58 yield selectNode(noimage, inspector); |
|
59 let noimageLink = ruleView.doc.querySelector(".ruleview-propertycontainer a"); |
|
60 ok(!noimageLink, "There is no link for the node with no background image"); |
|
61 } |