Facebook and Google on Wednesday defended working with anti-immigrant and anti-refugee ad campaigns to target voters online in swing states, even though the ads conflicted with the Silicon Valley companies’ public support for immigrants and refugees.

The ad teams of the two tech giants — which dominate the lucrative online advertising business — worked “closely” with Secure America Now, a right-wing group whose campaigns included anti-Hillary Clinton and anti-Muslim messages, according to a report from Bloomberg.

Ads appeared on Google properties and Facebook timelines to tout videos, such as one which imagines the “Islamic State of France,” complete with a hijab-clad Mona Lisa and schools “training a new generation of fighters.” The video, which remains on YouTube, appears to be meant to alarm people who might fear Muslims.

Experts at universities in Silicon Valley on Wednesday questioned whether the tech companies are giving due consideration up front to the implications of helping with such ads, or whether they ought to tighten their policies to prevent ads that promote dangerous biases and stereotypes.

The controversy echoes questions raised in the past over choices by social media and search companies about content they decide to leave up or take down from their sites, and whether they are effectively publishers that should more actively police content from their users.

The video ads are reminiscent of racially tinged political ads, such as the one featuring African-American felon Willie Horton when George H.W. Bush and Michael Dukakis battled for the presidency in 1988. The online videos are highly targeted ads “designed to strike fear in people’s hearts,” a former digital ad agency employee told Bloomberg.

“If it’s true, I’m disappointed that Google and Facebook weren’t more thoughtful about this,” said Eric Goldman, director of Santa Clara University’s High Tech Law Institute, in an interview Wednesday.

“Who owns this topic at Google and Facebook?” he asked. “If the answer is no one, then that’s a problem.”

Facebook didn’t work directly with Secure America Now, according to a company representative. The social network worked with ad agency Harris Media, which then worked with Secure America Now — a nonprofit organization created in the wake of the Sept. 11 attacks to fight against the construction of a mosque near Ground Zero in New York City.

Yet the chief executives of Facebook and Google, Mark Zuckerberg and Sundar Pichai, have spoken out against discrimination against Muslims, refugees and immigrants.

When asked for comment about the content of the video ads, a Facebook spokesman pointed to a recent media interview with Chief Operating Officer Sheryl Sandberg, in which she said Facebook must allow for free expression by its users even when it doesn’t agree with them.

“It’s not just content, it’s ads,” Sandberg told Axios. “Because when you’re thinking about political speech, ads are really important.”

But that gets into murkier territory.

“It’s one thing to have neutrality in terms of content,” said Irina Raicu, director for the Markkula Center for Applied Ethics at Santa Clara University, in an interview Wednesday. “When you get into ads, it’s a different issue. You absolutely get to choose which ads you feature on your platform.”

But Goldman said if the companies “reject [certain] advertising, that could have its own effect on political campaigns.”

For example, he said it wouldn’t make sense for the companies to only accept ads from liberal campaigns.

Get tech news in your inbox weekday mornings. Sign up for the free Good Morning Silicon Valley newsletter.

Raicu also said she thinks that after Facebook was accused last year of discriminating against conservative news sources, it is trying to be too neutral. By trying to appear less liberal-leaning, it’s overcompensating and is allowing content that doesn’t appear to blatantly violate its terms of service, she said.

As for Google, it later blocked some of the ads.

“We have strict policies that govern where we allow Google ads to appear, and we enforce these policies vigorously,” a Google spokeswoman said Wednesday. “When we find ads that violate these policies, we immediately disapprove and stop showing them.”

She did not deny claims in the Bloomberg report that Google employees physically “hunkered down” with Secure America Now and Harris Media to talk about how to improve their digital ad campaigns.

Facebook also reportedly tested Secure America Now video campaigns, which a company spokesman stressed was at the request of Harris Media.

Harris Media did not respond to a request for comment.

Other ads attempted to link Democratic Senate candidates with Syrian refugees and terrorists, according to the Bloomberg report.

The video that imagines Muslims taking over France was still viewable Wednesday on YouTube, and it appeared alongside recommendations for similar videos uploaded by users such as “AryanWarrior2012.” When asked about the video, a Google spokeswoman reiterated her statement that the company disapproves ads that violate its policies when they find them.

If some of these ads and videos don’t violate the companies’ policies, then “maybe the code of conduct is too open,” said John Delacruz, assistant professor of advertising at San Jose State University.

“There’s a line that an organization needs to consider, in which freedom of expression becomes a platform for hatred,” he said. “I don’t think they should be profiting from hate speech.”

The Bloomberg report follows disclosures that politically misleading ads with Russian ties appeared on Facebook and Google, and comes amid investigations into Russian meddling in the U.S. presidential election.