示例#1
0
def index():
    """Set the main view where people come to report issues."""
    push('/css/dist/webcompat.min.css', **{
        'as': 'style',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/webcompat.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push('/img/svg/icons/svg-leaf_right.svg', **{
        'as': 'img',
        'rel': 'preload'
    })
    push('/img/svg/icons/svg-leaf_left.svg', **{
        'as': 'img',
        'rel': 'preload'
    })
    ua_header = request.headers.get('User-Agent')
    bug_form = get_form({'user_agent': ua_header})

    # browser_name is used in topbar.html to show the right add-on link
    browser_name = get_browser_name(ua_header)
    # GET means you want to file a report.
    if g.user:
        get_user_info()
    return render_template('index.html', form=bug_form, browser=browser_name)
示例#2
0
def index():
    """Set the main view where people come to report issues."""
    push('/dist/webcompat.css', **{
        'as': 'style',
        'rel': 'preload'
    })
    push(bust_cache('/dist/vendor.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/webcompat.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/index.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    ua_header = request.headers.get('User-Agent')

    # browser_name is used in topbar.html to show the right add-on link
    browser_name = get_browser_name(ua_header)
    # GET means you want to file a report.
    if g.user:
        get_user_info()
    return render_template('index.html', browser=browser_name)
示例#3
0
 def test_get_browser(self):
     """Test browser parsing via get_browser helper method."""
     self.assertEqual(get_browser(FIREFOX_UA), 'Firefox 48.0')
     self.assertEqual(get_browser(FIREFOX_MOBILE_UA), 'Firefox Mobile 40.0')
     self.assertEqual(get_browser_name(FIREFOX_MOBILE_UA_OLD),
                      'firefox mobile')
     self.assertEqual(get_browser(FIREFOX_TABLET_UA),
                      'Firefox Mobile (Tablet) 41.0')
     self.assertEqual(get_browser(SAFARI_UA), 'Safari 9.0')
     self.assertEqual(get_browser(SAFARI_MOBILE_UA), 'Mobile Safari 6.0')
     self.assertEqual(get_browser(SAFARI_TABLET_UA), 'Mobile Safari 5.1')
     self.assertEqual(get_browser(CHROME_UA), 'Chrome 52.0.2720')
     self.assertEqual(get_browser(CHROME_MOBILE_UA),
                      'Chrome Mobile 18.0.1025')
     self.assertEqual(get_browser(CHROME_TABLET_UA), 'Chrome 18.0.1025')
     self.assertEqual(get_browser(''), 'Unknown')
     self.assertEqual(get_browser(), 'Unknown')
     self.assertEqual(get_browser('💀'), 'Unknown')
     self.assertEqual(get_browser('<script>lol()</script>'), 'Unknown')
     self.assertEqual(get_browser(True), 'Unknown')
     self.assertEqual(get_browser(False), 'Unknown')
     self.assertEqual(get_browser(None), 'Unknown')
示例#4
0
 def test_get_browser(self):
     '''Test browser parsing via get_browser helper method.'''
     self.assertEqual(get_browser(FIREFOX_UA), 'Firefox 48.0')
     self.assertEqual(get_browser(FIREFOX_MOBILE_UA), 'Firefox Mobile 40.0')
     self.assertEqual(get_browser_name(FIREFOX_MOBILE_UA_OLD),
                      'firefox mobile')
     self.assertEqual(get_browser(FIREFOX_TABLET_UA),
                      'Firefox Mobile (Tablet) 41.0')
     self.assertEqual(get_browser(SAFARI_UA), 'Safari 9.0')
     self.assertEqual(get_browser(SAFARI_MOBILE_UA), 'Mobile Safari 6.0')
     self.assertEqual(get_browser(SAFARI_TABLET_UA), 'Mobile Safari 5.1')
     self.assertEqual(get_browser(CHROME_UA), 'Chrome 52.0.2720')
     self.assertEqual(get_browser(CHROME_MOBILE_UA),
                      'Chrome Mobile 18.0.1025')
     self.assertEqual(get_browser(CHROME_TABLET_UA), 'Chrome 18.0.1025')
     self.assertEqual(get_browser(''), 'Unknown')
     self.assertEqual(get_browser(), 'Unknown')
     self.assertEqual(get_browser(u'💀'), 'Unknown')
     self.assertEqual(get_browser('<script>lol()</script>'), 'Unknown')
     self.assertEqual(get_browser(True), 'Unknown')
     self.assertEqual(get_browser(False), 'Unknown')
     self.assertEqual(get_browser(None), 'Unknown')
示例#5
0
 def test_get_browser_name(self):
     """Test browser name parsing via get_browser_name helper method."""
     self.assertEqual(get_browser_name(FIREFOX_UA), 'firefox')
     self.assertEqual(get_browser_name(FIREFOX_MOBILE_UA), 'firefox mobile')
     self.assertEqual(get_browser_name(FIREFOX_MOBILE_UA_OLD),
                      'firefox mobile')
     self.assertEqual(get_browser_name(FIREFOX_TABLET_UA),
                      'firefox mobile (tablet)')
     self.assertEqual(get_browser_name(SAFARI_UA), 'safari')
     self.assertEqual(get_browser_name(SAFARI_MOBILE_UA), 'mobile safari')
     self.assertEqual(get_browser_name(SAFARI_TABLET_UA), 'mobile safari')
     self.assertEqual(get_browser_name(CHROME_UA), 'chrome')
     self.assertEqual(get_browser_name(CHROME_MOBILE_UA), 'chrome mobile')
     self.assertEqual(get_browser_name(CHROME_TABLET_UA), 'chrome')
     self.assertEqual(get_browser_name(''), 'unknown')
     self.assertEqual(get_browser_name(None), 'unknown')
     self.assertEqual(get_browser_name(), 'unknown')
     self.assertEqual(get_browser_name('💀'), 'unknown')
     self.assertEqual(get_browser_name('<script>lol()</script>'), 'unknown')
     self.assertEqual(get_browser_name(True), 'unknown')
     self.assertEqual(get_browser_name(False), 'unknown')
     self.assertEqual(get_browser_name(None), 'unknown')
示例#6
0
 def test_get_browser_name_Non_Tablet(self):
     '''Test Browser name parsing for non-tablet devices.'''
     user_agent = NON_TABLET_UA
     parsed_browser_name = PARSED_NON_TABLET_BROWSER_NAME
     self.assertEqual(get_browser_name(user_agent), parsed_browser_name)
示例#7
0
 def test_get_browser_name(self):
     '''Test browser name parsing via get_browser_name helper method.'''
     self.assertEqual(get_browser_name(FIREFOX_UA), 'firefox')
     self.assertEqual(get_browser_name(FIREFOX_MOBILE_UA), 'firefox mobile')
     self.assertEqual(get_browser_name(FIREFOX_MOBILE_UA_OLD),
                      'firefox mobile')
     self.assertEqual(get_browser_name(FIREFOX_TABLET_UA),
                      'firefox mobile (tablet)')
     self.assertEqual(get_browser_name(SAFARI_UA), 'safari')
     self.assertEqual(get_browser_name(SAFARI_MOBILE_UA), 'mobile safari')
     self.assertEqual(get_browser_name(SAFARI_TABLET_UA), 'mobile safari')
     self.assertEqual(get_browser_name(CHROME_UA), 'chrome')
     self.assertEqual(get_browser_name(CHROME_MOBILE_UA), 'chrome mobile')
     self.assertEqual(get_browser_name(CHROME_TABLET_UA), 'chrome')
     self.assertEqual(get_browser_name(''), 'unknown')
     self.assertEqual(get_browser_name(None), 'unknown')
     self.assertEqual(get_browser_name(), 'unknown')
     self.assertEqual(get_browser_name(u'💀'), 'unknown')
     self.assertEqual(get_browser_name('<script>lol()</script>'), 'unknown')
     self.assertEqual(get_browser_name(True), 'unknown')
     self.assertEqual(get_browser_name(False), 'unknown')
     self.assertEqual(get_browser_name(None), 'unknown')
 def test_get_browser_name_Non_Tablet(self):
     '''Test Browser name parsing for non-tablet devices.'''
     user_agent = NON_TABLET_UA
     parsed_browser_name = PARSED_NON_TABLET_BROWSER_NAME
     self.assertEqual(get_browser_name(user_agent), parsed_browser_name)