This repository was archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathtc_show_injected.rb
More file actions
54 lines (46 loc) · 1.7 KB
/
Copy pathtc_show_injected.rb
File metadata and controls
54 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This test case checks whether the content at test.privly.org
# injects into the host page properly. These specs only
# run if the extension is loaded into the web browser.
class TestInjected < Test::Unit::TestCase
include Capybara::DSL # Provides for Webdriving
def test_google_groups_injection
visit "https://groups.google.com/forum/#!topic/privly/f6iBZ8Z-YMQ/discussion"
page.assert_selector("iframe[data-privly-display='true']", :count => 1)
end
def test_twitter_injection
visit "https://twitter.com/PrivlyTest/status/308809779655102464"
page.assert_selector("iframe[data-privly-display='true']", :count => 1)
end
def test_showing_injected_posts
# Open these pages
test_pages = [
"http://test.privly.org/test_pages/whitelist.html",
"http://test.privly.org/test_pages/url_parameters.html",
"http://test.privly.org/test_pages/misdirection.html",
"http://test.privly.org/test_pages/iframes.html"
]
test_pages.each do |test_page|
visit test_page
links = page.all(:css, ".replace_link")
links.each do |link|
assert link.has_xpath?('..//iframe')
end
end
end
def test_showing_injected_posts_reddit
visit "http://www.reddit.com/r/Privly/comments/2xipzl/privly_demonstration_link/"
page.assert_selector("iframe[data-privly-display='true']", :count => 1)
end
def test_non_whitelisted
# Open these pages
test_pages = ["http://test.privly.org/test_pages/nonwhitelist.html"]
test_pages.each do |test_page|
visit test_page
assert page.has_no_xpath?('//iframe') # The page should have no iframes.
end
end
def teardown
Capybara.reset_sessions!
Capybara.use_default_driver
end
end