Closed Bug 163639 Opened 22 years ago Closed 22 years ago

CNN video pops up javascript window with nothing

Categories

(Tech Evangelism Graveyard :: English US, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: nateg, Assigned: susiew)

References

(Blocks 1 open bug, )

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.1b) Gecko/20020722
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.1b) Gecko/20020722

On CNN's web site, when I click any video link I get a blank small window.  With
Internet Explorer I get a window that talks about paying CNN money for video, etc.

Reproducible: Always

Steps to Reproduce:
1. Go to cnn.com
2. Click on any link to play video.
3.

Actual Results:  
Small blank window pops up.

Expected Results:  
Larger window with stuff about having to pay CNN for video content.
this happens if you have set the javascript preference to disallow unrequested
new windows ... so i don't think it is a bug.
But it *is* a requested window.  Other windows pop up correctly.
Confirmed using Mac/2002080208/9.2.2. Clicking on the "Video" link next to "China lake 
threatens to flood millions" results in a small blank window opening. However, an error is 
generated on the JS Console, so this is probably a Tech Evangelism issue.

Error: popupWin has no properties
Source File: http://i.cnn.net/cnn/virtual/2000/code/main.js
Line: 280
Assignee: rogerl → susiew
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → US General
Ever confirmed: true
Product: Browser → Tech Evangelism
QA Contact: pschwartau → zach
Version: other → unspecified
                          EXPLANATION

The video links at CNN are not ordinary anchors with href = (some URL). 
Otherwise, they would work even if you have turned off the pref for
"Open unrequested windows". The CNN anchors call javascript:URLs;
that is, they call JavaScript functions to create new windows. The 
anchor I clicked on had href = "javascript:LaunchWindow( etc. etc.)".

If you have unchecked the "Open unrequested windows" pref, note this
actually sets the pref |dom.disable_open_during_load|. That means
no JavaScript call to window.open() will succeed during any page load. 


Now take a look at some of the CNN JavaScript:
http://i.cnn.net/cnn/virtual/2000/code/main.js


  function LaunchVideo(url, format)
  {
    fullurl = "/video/code/sniff.exclude.html?" + url + ";" + format;
    window.open(fullurl, "1x1TestWin", 
"toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=1,height=1")
;
  }


This creates |fullurl| = 
"http://www.cnn.com/video/code/sniff.exclude.html?/world/2002/08/20/nr.roots.of.
hate.cnn.;300k"


Later on:

        if (RealOneInst == "using") {
-  272        top.opener.location.href = using();
-  273  } else {
-  274        a = determineCookie();
-  275        if (a.indexOf(".exclude.html") > 0) {
-  276            openWindow(a, "620x480", 
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resiza
ble=no,width=620,height=480");
   277        } else {
-  278            top.opener.location.href = determineCookie();
   279        }
   280  }


In my session, the variable |a| above (a URL) turned out to be 
"http://premium.cnn.com/pr/video/world/2002/08/20/nr.roots.of.hate.cnn.exclude.h
tml"


Notice |a| is sent as the first parameter to this function:

function openWindow(earl, name, widgets) {
-   3         host = location.hostname;
-   4         if (host.indexOf("customnews") != -1) {
-   5             var url = "http://customnews.cnn.com" + earl;
    6         } else {
-   7             var url = earl;
    8         }
-   9         popupWin = window.open(url, name, widgets);

                       etc.
                       etc.

              if (!is_aol6 &&
-  24             !is_aol3 && !is_aol4 && !is_aol5 && !is_compie &&                                                           
                                                      !is_comp2000) {
-  25             popupWin.opener.top.name = "opener";
-  26             popupWin.focus();
   27         }
   28     }



If you have the pref allowing unrequested windows turned off,
line 9 above will not succeed:

-   9         popupWin = window.open(url, name, widgets);


As a result, the variable |popupWin| is assigned the value |null|.
Thus |popupWin| has no properties, and we get an error on line 25 above:

-  25             popupWin.opener.top.name = "opener";


This is the error seen by Greg in the JavaScript Console. Run-time
errors like this cause all JavaScript execution to stop - explaining
the problem the reporter is seeing.
typo above: the anchor href was "javascript:LaunchVideo( etc. etc.)",
not LaunchWindow().
Are your popups turned on or off?

If off, please mark this invalid. Thanks.
I was the one who reported this problem.  My unrequested popups are turned off
(unchecked).  But this is a requested popup, by my mouse click.
I'm using Gecko/20020819 commercial branch on Win2K and the video pop up works
for me. 
Mozilla trunk binary 20020805xx and 1.0 branch 20020806xx on WinNT.

I think we're all seeing the same thing: if you allow sites to open
unrequested windows, CNN video links brings up child windows just fine.
You get no errors in the JavaScript Console.

But if unrequested popups are turned off (unchecked), the CNN code
only gets as far as bringing up a small, empty window before generating
a run-time error:

    Error: popupWin has no properties
    Source File: http://i.cnn.net/cnn/virtual/2000/code/main.js
    Line: 280


This causes JS execution to stop, and you are left with the
small, empty window.

The reason for this is explained in Comment#4: the video anchors
do not have simple hrefs to http:URLs, they have javascript:URLs.
The JavaScript at CNN eventually tries to call window.open(), 
and this is what is getting blocked by the pref setting. 

The window.open() call is occurring during page load, which is
what the pref blocks. It stops any new window from being opened
while a page is loading.

cc'ing jruderman: have you seen this problem at other sites that
use javascript:URLs to open new windows? From a user's perspective,
clicking on a link is an assent to a new window.

However, the way CNN has coded this, it triggers the very thing
the "unrequested window" pref is designed to block -
I can confirm this with 1.1b / win2k / 20020815 where the popup appears and it
contains an empty document.

I do not have any restrictions set on popups etc and get no js errors.

If I change my user agent to ns7 then this works fine. Definitely evangelism.

Daniel, Can you contact the CNN folks and ask them to allow any Gecko browser to
access their content? Otherwise they will be in deep doo doo when there are
booqoo clients using Gecko and they don't detect them all. :-)
Email sent off to the CNN video development group.
Just spoke with the video group. We're going to work on it, but any pointers as 
to the best way to fix it would be help us to fix it faster.
Here is some of the browser-sniffing done at the site. Note it is
not centralized, and is repeated in-line within different functions
in http://i.cnn.net/cnn/virtual/2000/code/main.js:


// this is for opening pop-up windows
function openWindow (earl,name,widgets) 
{
  host = location.hostname;
  if (host.indexOf('customnews') != -1) 
  {
    var url = 'http://customnews.cnn.com' + earl;
  }
  else
  {
    var url = earl;
  }
  popupWin = window.open (url,name,widgets);
	
  var agt=navigator.userAgent.toLowerCase();
  var is_major = parseInt(navigator.appVersion);
  var is_ie   = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
  var is_ie3  = (is_ie && (is_major < 4));
  var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
  var is_aol  = (agt.indexOf("aol") != -1);
  var is_aol3 = (is_aol && is_ie3);
  var is_aol4 = (is_aol && is_ie4);
  var is_aol5 = (agt.indexOf("aol 5") != -1);
  var is_aol6 = (agt.indexOf("aol 6") != -1);
  var is_comp = (agt.indexOf("compuserve") != -1);
  var is_comp2000  = (agt.indexOf("cs") != -1);	 
  var is_compie    = (is_comp && is_ie);

  if(!is_aol6 && !is_aol3 && !is_aol4 && !is_aol5 && !is_compie && !is_comp2000)   
  {
    popupWin.opener.top.name = "opener";
    popupWin.focus();
  }
}
And here are global variables defined at the top of the file:

var browser = "";
var browsername = navigator.appName;
var browserversion = parseInt(navigator.appVersion);

if (browsername == "Netscape") 
{
  browser = "ns" + browserversion;
}
else
{
  if (browsername == "Microsoft Internet Explorer") 
  {
    if (browserversion >= 4) 
    {
      browser = "ie" + browserversion;
    }
    else 
    {
      browser = "ie3";
    }
  }
}

bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
And from http://www.cnn.com/video/code/sniff.exclude.html: 
	
var agt=navigator.userAgent.toLowerCase();
var is_nav  = ((agt.indexOf('mozilla')!=-1) &&
               (agt.indexOf('spoofer')==-1) &&
               (agt.indexOf('compatible') == -1) &&
               (agt.indexOf('opera')==-1) &&
               (agt.indexOf('webtv')==-1) &&
               (agt.indexOf('hotjava')==-1));

if (is_nav) {
 IERPCtl = 0;
}
Blocks: 118315
We are working on it. We've determined it is due to the pop up blocking code in 
mozilla and will be adding in a detection into our javascript.
CNN video links do use javascript:, but this isn't the problem.  The problem is
that the javascript: link opens a tiny intermediate window rather than the final
video window.  The document loaded in the intermediate window is blank but
contains javascript.  This script opens a larger new window, uses a reference to
the new window to do a few things (rename the original window to "opener" and
focus the new window), and finally closes the intermediate window.  Mozilla
disallows opening the second new window.  The intermediate window is not closed
in Mozilla because the script tries to use a reference to a window that never
opened, causing the "tiny blank window" result.

Mozilla is correct in blocking the second window.open, because it happens as
part of the loading of the intermediate document.  CNN can fix this problem by
eliminating the use of an intermediate window.  (An intermediate *document* in
the same window as the video would be fine.  Resizing the window between the
intermediate document and the final document would be ok but nice to avoid.)  In
response to comment 16, I don't see how detecting Mozilla would help.
OS: Mac System 9.x → All
Hardware: Macintosh → All
Blocks: popups
Keywords: evang500
the popups now have the registration/payment info and are no longer blank. ->
fixed. please reopen if you disagree
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Product: Tech Evangelism → Tech Evangelism Graveyard
You need to log in before you can comment on or make changes to this bug.