Closed Bug 848854 Opened 11 years ago Closed 11 years ago

deadline.com doesn't recognize B2G UA as mobile

Categories

(Web Compatibility :: Site Reports, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: lmandel, Assigned: karlcow)

References

()

Details

(Whiteboard: [uaoverride] [country-all] [sitewait] [clientsniff])

deadline.com serves a desktop site to B2G. Bug 823364 added an UA override for this domain. The override should be removed once the domain serves mobile content to B2G. This bug tracks the evangelism for the site to recognize the B2G UA and the removal of the override at that time.
Blocks: deadline.com
Whiteboard: [uaoverride]
CONFIRMED.

On all browsers/devices:
http://www.deadline.com/ redirects to http://www.deadline.com/hollywood/

Then there is a script for the redirection which redirects to 
http://m.deadline.com/hollywood/

It checks if there is a cookie already identifying as mobile. So For testing it is important to clear the cookies each time. Then when the cookie is not here it tests for different strings for user agents.

    var mobile_user_agents = ["alcatel","amoi","android","audiovox","avantgo","benq","blackberry",
"cdm","danger","dopod","ericsson","fly","haier","htc","huawei",
"i-mobile","iemobile 7","iphone","ipod","j-phone","kddi","kwc",
"kyocera/wx310k","lenovo","lg/u990","lge vx","maemo",
"mot-v","motorola","netfront","newt","nintendo ds","nitro","nokia",
"novarra","opera mini","palm","panasonic","pantech","philips","pixi",
"playstation portable","portalmmm","qtek","sagem","samsung","sanyo",
"sch-u960","scp6760","sharp","small","softbank","sonyericsson",
"sph-m810","symbian","t-mobile g1","toshiba","treo","treo850",
"vertu","webos","windows phone","xda","zte"];


None of these are testing for mobile :)


Here the full script. 

> <script type="text/javascript">
> detect_mobile_useragent();
> function detect_mobile_useragent() {
>     var mobile_cookie_name = "show_mobile";
>     var mobile_cookie_value = "";
> 
>     if (document.cookie.length > 0) {
>         cookie_start = document.cookie.indexOf(mobile_cookie_name + "=");
>         if (cookie_start != -1) {
>             cookie_start = cookie_start + mobile_cookie_name.length + 1;
>             cookie_end = document.cookie.indexOf(";", cookie_start);
>             if (cookie_end == -1)
>                 cookie_end = document.cookie.length;
>             mobile_cookie_value = unescape(document.cookie.substring(cookie_start, cookie_end));
>         }
>     }
> 
>     if ( document.referrer == "" || document.referrer.indexOf("http://www.deadline.com") == -1 ) {
>         var exp_date=new Date();
>         exp_date.setDate(exp_date.getDate() + 1);
>         document.cookie = "mobile_referrer=" + encodeURIComponent(document.referrer) + ";expires=" + exp_date.toGMTString() + ";path=/;domain=.deadline.com";
>     }
> 
>     if ( "1" == mobile_cookie_value ) {
>         // Redirect to mobile
>         //console.log("Cookie == 1, will redirect");
>         window.parent.location.replace("http://m.deadline.com/hollywood/");
>         return;
>     } else if ( "0" == mobile_cookie_value ) {
>         // Will not redirect, cookie already set
>         //console.log("Cookie == 0, will not redirect");
>         return;
>     }
> 
>     // Cookie not found
>     var mobile_user_agents = ["alcatel","amoi","android","audiovox","avantgo","benq","blackberry","cdm","danger","dopod","ericsson","fly","haier","htc","huawei","i-mobile","iemobile 7","iphone","ipod","j-phone","kddi","kwc","kyocera/wx310k","lenovo","lg/u990","lge vx","maemo","mot-v","motorola","netfront","newt","nintendo ds","nitro","nokia","novarra","opera mini","palm","panasonic","pantech","philips","pixi","playstation portable","portalmmm","qtek","sagem","samsung","sanyo","sch-u960","scp6760","sharp","small","softbank","sonyericsson","sph-m810","symbian","t-mobile g1","toshiba","treo","treo850","vertu","webos","windows phone","xda","zte"];
>     var current_user_agent = navigator.userAgent.toLowerCase();
>     for (i = 0; i < mobile_user_agents.length; i++) {
>         var regex = new RegExp(mobile_user_agents[i], 'gi');
>         if ( current_user_agent.match(regex) ) {
>             // Set is_mobile cookie
>             var exp_date=new Date();
>             exp_date.setDate(exp_date.getDate() + 365);
>             document.cookie = mobile_cookie_name + "=" + escape(1) + ";expires=Thursday, 31-Jul-14 00:00:00 UTC;path=/;domain=.deadline.com";
> 
>             // Redirect to mobile
>             //console.log("Cookie set to 1, will redirect");
>             window.parent.location.replace("http://m.deadline.com/hollywood/");
>             return;
>         }
>     }
> 
>     // Set is_mobile=0 cookie
>     var exp_date=new Date();
>     exp_date.setDate(exp_date.getDate() + 365);
>     document.cookie = mobile_cookie_name + "=" + escape(0) + ";expires=Thursday, 31-Jul-14 00:00:00 UTC;path=/;domain=.deadline.com";
>     //console.log("Cookie set to 0, will not redirect");
>     return;
> }
> </script>
Assignee: nobody → kdubost
Contacted Business Development - bizdev@pmc.com http://www.pmc.com/contact/
This is the company owning the site deadline.com
Whiteboard: [uaoverride] → [uaoverride] [country-all] [sitewait]
Thanks for bringing this to our attention, it has been fixed - we now recognize "mobile" as a mobile UA on deadline.com.
(In reply to dist.dev from comment #3)
> Thanks for bringing this to our attention, it has been fixed - we now
> recognize "mobile" as a mobile UA on deadline.com.

That's great. Thanks! By the way, if you recognize the "Mobi" token instead of "Mobile" you'll include the largest number of mobile clients.
Whiteboard: [uaoverride] [country-all] [sitewait] → [uaoverride] [country-all] [sitewait] [clientsniff]
Status: NEW → ASSIGNED
This is fixed indeed.
var mobile_user_agents = ["alcatel",
[…]
,"zte","mobile"];
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Blocks: 932040
Product: Tech Evangelism → Web Compatibility
Component: Mobile → Site Reports
You need to log in before you can comment on or make changes to this bug.